string类(使用+实现)(C++)

news2024/9/22 4:16:06

string

  • string类“登场”
  • string类 - 了解
  • string类的常用接口
    • 常见构造
    • 容量操作
    • 访问及遍历操作
      • 迭代器
        • 分类
        • 作用
    • 增删查改操作
    • 非成员函数
  • string类的实现
    • string类重要的方法实现分析介绍
      • 构造函数
      • 拷贝构造函数
      • 赋值运算符重载
      • 总结
    • string类整体实现代码
  • 写时拷贝(了解)
  • vs2019中的buffer数组

严格的来说string出现的时候是早于STL

string类“登场”

在C语言中,字符串是以’\0’结尾的一些字符的集合,为了方便C标准库提供了一些str系列的函数。但是库函数和字符串是分割开的,不符合OOP(面向对象编程)思想,而且底层空间需要自己管理,不注意可能就会出现越界。
为了解决上述问题,所以出现了string类。

string类 - 了解

  1. string是表示字符串的类
  2. 该类的接口和常规容器的接口基本相同,并且添加了一些专门用来操作string的常规操作。

string类的常用接口

使用接口时要包含头文件

#include <string>

常见构造

(constructor)函数名称功能说明
string()构造空的string类对象,即空字符串
string(const char* s)用C-string来构造string类对象
string(const string& s)拷贝构造函数
string(size_t n, char c)string类对象中包含n个字符

test:

void Test_string()
{
	string s1;
	string s2("hello");
	string s3(s2);
	string s4(10, 'x');
}

容量操作

函数名称功能说明
size返回字符串有效字符长度
capacity返回空间总大小
empty检测字符串释放为空串
clear清空有效字符(改变size,不改变capacity)
reserve为字符串开空间
resize将有效字符个数改成n个,多出的空间用字符’c’填充。没有’c’,用0填充

test:

void Test_string()
{
	string s1("hello");
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;
	cout << s1.empty() << endl;

	s1.clear();
	cout << "new1_size:" << s1.size() << endl;
	cout << "new1_capacity:" << s1.capacity() << endl;
	
	s1.reserve(10);
	cout << "new2_size:" << s1.size() << endl;
	cout << "new2_capacity:" << s1.capacity() << endl;

	s1.reserve(50);
	cout << "new3_size:" << s1.size() << endl;
	cout << "new3_capacity:" << s1.capacity() << endl;

	s1.resize(60, 'x');
	cout << s1 << endl;
	cout << "new4_size:" << s1.size() << endl;
	cout << "new4_capacity:" << s1.capacity() << endl;
	
	s1.resize(70);
	cout << s1 << endl;    
	cout << "new5_size:" << s1.size() << endl;
	cout << "new5_capacity:" << s1.capacity() << endl;
}

访问及遍历操作

函数名称功能说明
operator[]返回pos位置的字符
begin + end迭代器,左闭右开
rbegin + rend反向迭代器,左闭右开
范围for遍历方式

test1: operator[]

void Test_string()
{
	string s1("hello");

	//operator[]重载了两个
	//char& operator[] (size_t pos);
	//const char& operator[] (size_t pos) const;

	for (size_t i = 0; i < s1.size(); i++)
	{
		s1[i]++;
		cout << s1[i] << " ";
	}
	cout << endl;

	const string s2("world");
	for (size_t i = 0; i < s2.size(); i++)
	{
		//s2[i]++;     //error
		cout << s2[i] << " ";
	}
	cout << endl;
}

test2: 迭代器,反向迭代器,范围for

void Test_string()
{
	string s1("hello");
	//迭代器
	string::iterator it = s1.begin();
	while (it != s1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;
	
	//反向迭代器
	string::reverse_iterator rit = s1.rbegin();
	while (rit != s1.rend())
	{
		cout << *rit << " ";
		++rit;
	}
	cout << endl;

	//const迭代器
	const string s2("world");
	string::const_iterator c_it = s2.begin();
	while (c_it != s2.end())
	{
		cout << *c_it << " ";
		++c_it;
	}
	cout << endl;

	//const反向迭代器
	string::const_reverse_iterator c_rit = s2.rbegin();
	while (c_rit != s2.rend())
	{
		cout << *c_rit << " ";
		++c_rit;
	}
	cout << endl;

	//范围for
	for (auto ch : s2)
	{
		cout << ch << " ";
	}
	cout << endl;
}

迭代器

在上面的例子中,展现了迭代器的一些作用

分类

分类迭代器反向迭代器
普通迭代器iteratorreverse_iterator
const迭代器const_iteratorconst_reverse_iterator

作用

  1. 迭代器提供一种统一的方式访问和修改容器的数据
  2. 算法通过迭代器去处理容器的数据

增删查改操作

函数名称功能说明
push_back尾插字符
append在字符串后追加字符串
operator+=追加字符串str
c_str返回C格式字符串
erase删除
insert插入
assign将内容分配给字符串
find + npos从pos位置开始往后找字符,返回该字符在字符串中的位置
rfind从pos位置开始往前找字符,返回该字符在字符串中的位置
substr在str中从pos位置开始,截取n个字符,然后返回

test1: 增删改操作

void Test_string()
{
	string s1 = "hello";

	//void push_back (char c);
	s1.push_back(' ');
	cout << s1 << endl;

	//append
	//string& append(size_t n, char c);
	s1.append(2, ' ');
	//string& append(const char* s, size_t n);
	s1.append("world!", 6);
	cout << s1.c_str() << endl;

	//operator+=
	s1 += " 6666";
	cout << s1.c_str() << endl;

	//assign
	s1.assign("xxxxxxxxxxyyxxxxx");
	cout << s1 << endl;

	//erase
	//string& erase (size_t pos = 0, size_t len = npos);
	//从第10个位置开始删除两个字符
	s1.erase(10, 2);
	cout << s1 << endl;
	//全部删除
	s1.erase();
	cout << "erase after:" << s1 << endl;


	//insert
	s1.insert(0, "hello new !");
	cout << s1 << endl;
	//从s1第10个位置开始插入字符串的13个字符
	s1.insert(10, "kang peng lei ....", 13);
	cout << s1 << endl;
	cout << s1.size() << endl;
	s1.insert(s1.size(), 5, 'x');
	cout << s1 << endl;
}

test2: 查找和substr

void Test_string()
{
	string s1("hello kang peng lei!");

	//c_str
	char* c_s1 = new char[s1.size() + 1];
	strcpy(c_s1, s1.c_str());
	cout << s1.c_str() << endl;
	cout << c_s1 << endl;
	delete[] c_s1;


	//find
	string s2("https://legacy.cplusplus.com/reference/string/string/find/:");

	//从第3个数开始匹配
	size_t n2 = s2.find("://", 3);
	cout << "pos2:" << n2 << endl;
	string s3(".com/");

	//从s2最开始的地方开始匹配s3
	size_t n3 = s2.find(s3);
	cout << "pos3:" << n3 << endl;

	//从s2第2个位置匹配"om/re"的前三个字母
	size_t n4 = s2.find("om/re", 2, 3);
	cout << "pos4:" << n4 << endl;

	//从第十个位置匹配':'
	size_t n5 = s2.find(':', 10);
	cout << "pos5:" << n5 << endl;


	//substr
	//string substr(size_t pos = 0, size_t len = npos) const;
	string s4;
	s4 = s2.substr(0, 5);
	cout << "s4:" << s4 << endl;
	//从5开始输出十个字符
	string s5 = s2.substr(5, 10);
	cout << "s5:" << s5 << endl;


	string s6("Please, replace the vowels in this sentence by asterisks.");
	size_t found = s6.find(" ");
	size_t pos = 0;

	//find + npos
	while (found != string::npos)
	{
		cout << s6.substr(pos, found - pos) << " ";
		pos = found;
		found = s6.find(" ", found + 1);
	}

	cout << endl;
}

非成员函数

函数名称功能说明
operator>>流提取运算符重载
operator<<流插入运算符重载
getline获取一行字符串
relational operators运算符重载(大小比较)

test:

//getline
void Test_string()
{
	string name;
	getline(cin, name);
	cout << "Hello, " << name << "!\n";
}

string类的实现

string类重要的方法实现分析介绍

构造函数

	//带参构造函数
	//string(const char* str)
	//	:_size(strlen(str))
	//	,_capacity(_size + 1)
	//	,_str(new char[_capacity])
	//{
	//	strcpy(_str, str);
	//}
	//默认构造函数
	//string()
	//	:_size(0)
	//	,_capacity(1)
	//	,_str(new char[1])
	//{
	//	_str[0] = '\0';
	//}
	
	//构造函数
	string(const char* str = "")
	{
		assert(str != nullptr);
	
		_size = strlen(str);
		_capacity = _size + 1;
		_str = new char[_capacity];
		memcpy(_str, str, _size + 1);
	}

构造函数

拷贝构造函数

	//拷贝构造函数
	string(const string& s)
	{
		_str = new char[s._capacity + 1];
		memcpy(_str, s._str, s._size + 1);
		_size = s._size;
		_capacity = s._capacity;
	}

	//现代版本的拷贝构造函数
	//有缺陷"hello\0world" 
	//而且要初始化,不初始化交换给tmp会出问题
	/*string(const string& s)
		:_str(nullptr)
		, _size(0)
		, _capacity(0)
	{
		//有缺陷是因为这里使用字符串拷贝的
		string tmp(s._str);
		swap(tmp);
	}*/

拷贝构造函数

赋值运算符重载

	//运算符重载
	//s1 = s2
	/*string& operator=(const string& s)
	{
		if (this != &s)
		{
			char* tmp = new char[s._size + 1];
			memcpy(tmp, s._str, s._size + 1);

			delete[] _str;
			_str = tmp;
			_size = s._size;
			_capacity = s._capacity;
		}
		return *this;
	}*/

	void swap(string& s)
	{
		std::swap(_str, s._str);
		std::swap(_size, s._size);
		std::swap(_capacity, s._capacity);
	}

	//string& operator=(const string& s)
	//{
	//	if (this != &s)
	//	{
	//		string tmp(s);
	//		
	//		//this->swap(tmp)
	//		swap(tmp);
	//	}
	//	return *this;
	//}

	string& operator=(string tmp)
	{
		swap(tmp);
		return *this;
	}

赋值运算符重载

总结

因为涉及到开空间,所以构造函数,拷贝构造,赋值运算符重载,析构函数,都需要显示实现

string类整体实现代码

#include <iostream>
#include <assert.h>
using namespace std;

namespace kpl
{
	class string
	{
	public:
		const static size_t npos;

		//迭代器和const迭代器
		typedef char* iterator;
		typedef const char* const_iterator;

		iterator begin()
		{
			return _str;
		}
		iterator end()
		{
			return _str + _size;
		}

		const_iterator begin() const
		{
			return _str;
		}
		const_iterator end() const
		{
			return _str + _size;
		}


		带参构造函数
		//string(const char* str)
		//	:_size(strlen(str))
		//	,_capacity(_size + 1)
		//	,_str(new char[_capacity])
		//{
		//	strcpy(_str, str);
		//}
		默认构造函数
		//string()
		//	:_size(0)
		//	,_capacity(1)
		//	,_str(new char[1])
		//{
		//	_str[0] = '\0';
		//}
		//构造函数
		string(const char* str = "")
		{
			assert(str != nullptr);

			_size = strlen(str);
			_capacity = _size + 1;
			_str = new char[_capacity];
			memcpy(_str, str, _size + 1);
		}

		//拷贝构造函数
		string(const string& s)
		{
			_str = new char[s._capacity + 1];
			memcpy(_str, s._str, s._size + 1);
			_size = s._size;
			_capacity = s._capacity;
		}

		//现在版本的拷贝构造函数
		//有缺陷"hello\0world" 
		//而且要初始化,不初始化交换给tmp会出问题
		/*string(const string& s)
			:_str(nullptr)
			, _size(0)
			, _capacity(0)
		{
			//有缺陷是因为这里使用字符串拷贝的
			string tmp(s._str);
			swap(tmp);
		}*/



		//运算符重载
		//s1 = s2
		/*string& operator=(const string& s)
		{
			if (this != &s)
			{
				char* tmp = new char[s._size + 1];
				memcpy(tmp, s._str, s._size + 1);

				delete[] _str;
				_str = tmp;
				_size = s._size;
				_capacity = s._capacity;
			}
			return *this;
		}*/

		void swap(string& s)
		{
			std::swap(_str, s._str);
			std::swap(_size, s._size);
			std::swap(_capacity, s._capacity);
		}

		//string& operator=(const string& s)
		//{
		//	if (this != &s)
		//	{
		//		string tmp(s);
		//		
		//		//this->swap(tmp)
		//		swap(tmp);
		//	}
		//	return *this;
		//}

		string& operator=(string tmp)
		{
			swap(tmp);
			return *this;
		}

		//析构函数
		~string()
		{
			delete[] _str;
			_str = nullptr;
			_size = 0;
			_capacity = 0;
		}

		//返回一个c类型的常量字符串
		const char* c_str() const
		{
			return _str;
		}
		size_t capacity() const
		{
			return _capacity;
		}

		size_t size() const
		{
			return _size;
		}

		//重载[]
		char& operator[](size_t pos)
		{
			assert(pos < _size);

			return _str[pos];
		}
		const char& operator[](size_t pos) const
		{
			assert(pos < _size);

			return _str[pos];
		}

		//扩容
		void reserve(size_t n)
		{
			if (n > _capacity)
			{
				char* tmp = new char[n + 1];
				memcpy(tmp, _str, _size + 1);

				delete[] _str;
				_str = tmp;
				_capacity = n + 1;
			}
		}

		void resize(size_t n, char ch = '\0')
		{
			if (n < _size)
			{
				_size = n;
				_str[_size] = '\0';
			}
			else
			{
				//扩容
				reserve(n);

				for (size_t i = _size; i < n; i++)
				{
					_str[i] = ch;
				}
				_size = n;
				_str[_size] = '\0';
			}
		}

		void push_back(char ch)
		{
			if (_size == _capacity - 1)
			{
				reserve(_capacity == 1 ? 4 : 2 * _capacity);
			}

			_str[_size] = ch;
			++_size;
			_str[_size] = '\0';
		}

		void append(const char* str)
		{
			size_t len = strlen(str);
			if (_size + len >= _capacity)
			{
				reserve(_size + len);
			}
			memcpy(_str + _size, str, len);
			_size += len;
			_str[_size] = '\0';
		}

		string& operator+=(char ch)
		{
			push_back(ch);
			return *this;
		}

		string& operator+=(const char* str)
		{
			append(str);
			return *this;
		}

		void insert(size_t pos, size_t n, char ch)
		{
			assert(pos < _size);
			if (n + _size > _capacity - 1)
			{
				reserve(n + _size);
			}

			//挪动数据
			//第一种方法
			/*int end = _size;
			while (end >= (int)pos)
			{
				_str[end + n] = _str[end];
				--end;
			}*/

			//第二种方法
			/*size_t end = _size;
			while (end >= pos && end != npos)
			{
				_str[end + n] = _str[end];
				--end;
			}


			for (size_t i = 0; i < n; i++)
			{
				_str[i + pos] = ch;
			}
			_size += n;*/

			//第三种方法
			size_t end = _size + n;
			while (end >= pos + n)
			{
				_str[end] = _str[end - n];
				--end;
			}

			for (size_t i = 0; i < n; i++)
			{
				_str[i + pos] = ch;
			}
			_size += n;

		}

		void insert(size_t pos, const char* str)
		{
			assert(pos <= _size);
			size_t len = strlen(str);
			if (_size + len > _capacity - 1)
			{
				reserve(len + _size);
			}

			size_t end = _size + len;
			while (end >= pos + len)
			{
				_str[end] = _str[end - len];
				--end;
			}

			for (size_t i = 0; i < len; i++)
			{
				_str[i + pos] = str[i];
			}
			_size += len;
		}

		void erase(size_t pos, size_t len = npos)
		{
			assert(pos <= _size);

			if (len == npos || pos + len >= _size)
			{
				_str[pos] = '\0';
				_size = pos;
			}
			else
			{
				size_t end = pos + len;
				while (end <= _size)
				{
					_str[pos++] = _str[end++];
				}
				_size -= len;
			}
		}

		size_t find(char ch, size_t pos = 0) const
		{
			assert(pos < _size);

			for (size_t i = pos; i < _size; i++)
			{
				if (_str[i] == ch)
				{
					return i;
				}
			}
			return npos;
		}

		size_t find(const char* str, size_t pos = 0) const
		{
			assert(pos < _size);

			const char* ptr = strstr(_str + pos, str);

			return ptr == nullptr ? npos : ptr - _str;
		}

		string substr(size_t pos = 0, size_t len = npos) const
		{
			assert(pos < _size);
			size_t n = len;
			if (len == npos || pos + len > _size)
			{
				n = _size - pos;
			}

			string tmp;
			tmp.reserve(n);
			//i从开始到结束要有n个数据加到tmp所以终止条件是pos+n
			for (size_t i = pos; i < pos + n; i++)
			{
				tmp += _str[i];
			}
			return tmp;
		}

		void clear()
		{
			_str[0] = '\0';
			_size = 0;
		}

		//运算符重载 < 第一种写法
		bool operator<(const string& s) const
		{
			size_t n1 = 0;
			size_t n2 = 0;
			while (n1 < _size && n2 < s._size)
			{
				if (_str[n1] < s._str[n2])
				{
					return true;
				}
				else if (_str[n1] > s._str[n2])
				{
					return false;
				}
				else
				{
					n1++;
					n2++;
				}
			}

			return n1 == _size && n2 != s._size;

			//return _size < s._size;
		}

		//第二种写法
		/*bool operator<(const string& s) const
		{
			int ret = memcmp(_str, s._str, _size < s._size ? _size : s._size);

			return ret == 0 ? _size < s._size : ret < 0;
		}*/

		bool operator==(const string& s) const
		{
			return _size == s._size && memcmp(_str, s._str, _size) == 0;
		}
		
		bool operator<=(const string& s) const
		{
			return *this < s || *this == s;
		}
		bool operator>(const string& s) const
		{
			return !(*this <= s);
		}
		bool operator>=(const string& s) const
		{
			return !(*this < s);
		}
		bool operator!=(const string & s) const
		{
			return !(*this == s);
		}



	private:
		size_t _size;
		size_t _capacity;
		char* _str;
	};

	const size_t string::npos = -1;


	//流插入和流提取运算符重载
	ostream& operator<<(ostream& _cout, const string& s)
	{
		for (auto e : s)
		{
			_cout << e;
		}
		return _cout;
	}

	istream& operator>>(istream& _cin, string& s)
	{
		s.clear();

		//读取一个字符
		char ch = _cin.get();
		while (ch == ' ' || ch == '\n')
		{
			ch = _cin.get();
		}

		//节约空间
		char buf[128];
		int i = 0;
		while (ch != ' ' && ch != '\n')
		{
			buf[i++] = ch;
			if (i == 127)
			{
				buf[i] = '\0';
				s += buf;
				i = 0;
			}
			ch = _cin.get();
		}

		if (i != 0)
		{
			buf[i] = '\0';
			s += buf;
		}
		return _cin;
	}
}

写时拷贝(了解)

写时拷贝

vs2019中的buffer数组

buffer

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/811855.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

金三银四好像消失了,IT行业何时复苏!

疫情时候不敢离职&#xff0c;以为熬过来疫情了&#xff0c;行情会好一些&#xff0c;可是疫情结束了&#xff0c;反而行情更差了&#xff0c; 这是要哪样 我心中不由一万个 草泥&#x1f434; 路过 我心中不惊有了很多疑惑和感叹&#xff01; 自我10连问 我的心情 自去年下…

什么是合者生情?

有人说&#xff0c;自己的命运自己掌握&#xff0c;但必须以预知自己命运如何为前提。 若不知道自己的命运如何&#xff0c;却要掌握自己的命运&#xff0c;那只是一句空话&#xff0c;是自欺欺人。 而易学在我国历史上&#xff0c;直至现在&#xff0c;都起到了重大而深远的作…

Python入门【LEGB规则、面向对象简介、面向过程和面向对象思想、面向对象是什么? 对象的进化 、类的定义、对象完整内存结构 】(十三)

&#x1f44f;作者简介&#xff1a;大家好&#xff0c;我是爱敲代码的小王&#xff0c;CSDN博客博主,Python小白 &#x1f4d5;系列专栏&#xff1a;python入门到实战、Python爬虫开发、Python办公自动化、Python数据分析、Python前后端开发 &#x1f4e7;如果文章知识点有错误…

ARM裸机-5

1、可编程器件的编程原理 1.1、电子器件的发展方向 模拟器件-->数字器件 ASIC-->可编程器件 1.2、可编程器件的特点 CPU在固定频率的时钟控制下节奏运行。 CPU可以通过总线读取外部存储设备中的二进制指令集&#xff0c;然后解码执行。 这些可以被CPU解码执行的二进制指…

SpringBoot临时属性设置

在Spring Boot中&#xff0c;可以通过设置临时属性来覆盖应用程序中定义的属性。这在某些情况下很有用&#xff0c;例如在命令行中指定配置参数或在测试环境中覆盖默认值。 你可以使用--&#xff08;双破折号&#xff09;语法来设置临时属性。以下是一些示例&#xff1a; 1. …

【点云处理教程】04 Python 中的点云过滤

一、说明 这是我的“点云处理”教程的第 4 篇文章。“点云处理”教程对初学者友好&#xff0c;我们将在其中简单地介绍从数据准备到数据分割和分类的点云处理管道。 在本教程中&#xff0c;我们将学习如何使用 Open3D 在 python 中过滤点云以进行下采样和异常值去除。使用 Open…

【GitOps系列】在 GitOps 工作流中实现蓝绿发布

文章目录 前言蓝绿发布概述手动实现蓝绿发布创建蓝色环境创建蓝色环境 Ingressroute部署绿色环境切换到绿色环境 蓝绿发布自动化安装 Argo Rollout创建 Rollout 对象创建 Service 和 Ingress访问蓝色环境发布自动化 访问 Argo Rollout Dashboard自动化原理结语 前言 在前几篇【…

Netty学习(四)

文章目录 四. 优化与源码1. 优化1.1 扩展序列化算法jdk序列化与反序列化Serializer & AlgorithmConfigapplication.properties MessageCodecSharableMessage&#xff08;抽象类&#xff09; 测试序列化测试反序列化测试 1.2 参数调优1&#xff09;CONNECT_TIMEOUT_MILLIS2&…

最强,自动化测试-自定义日志类及日志封装(实战)

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 在自定义日志之前…

【机器学习】习题3.3Python编程实现对数几率回归

参考代码 结合自己的理解&#xff0c;添加注释。 代码 导入相关的库 import numpy as np import pandas as pd import matplotlib from matplotlib import pyplot as plt from sklearn import linear_model导入数据&#xff0c;进行数据处理和特征工程 # 1.数据处理&#x…

Windows系统如何修改文件日期属性

winr键&#xff0c;输入powershell,在弹出的命令窗口输入命令&#xff0c;案例如下&#xff1a; file_address E:\_OrderingProject\\PIC1101\ldv1s_0830_ec_result.tiftime_change "07/12/2022 20:42:23" 修改文件创建时间&#xff1a;creationtime $(Get-Item fi…

COMSOL三维Voronoi图泰森多边形3D模型轴压模拟及建模教程

多晶体模型采用三维Voronoi算法生成&#xff0c;试件尺寸为150150300mm棱柱模型&#xff0c;对晶格指定五种不同材料&#xff0c;实现晶格间的差异性。 对试件进行力学模拟&#xff0c;下侧为固定边界&#xff0c;限制z方向的位移&#xff0c;上表面通过给定位移的方式实现轴…

P2P网络NAT穿透原理(打洞方案)

1.关于NAT NAT技术&#xff08;Network Address Translation&#xff0c;网络地址转换&#xff09;是一种把内部网络&#xff08;简称为内网&#xff09;私有IP地址转换为外部网络&#xff08;简称为外网&#xff09;公共IP地址的技术&#xff0c;它使得一定范围内的多台主机只…

某拍房数据采集

某拍房数据采集 某拍房数据采集声明1.逆向目标2.寻找加密位置3.分析加密参数4.python代码书写 某拍房数据采集 声明 本文章中所有内容仅供学习交流&#xff0c;抓包内容、敏感网址、数据接口均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的…

yo!这里是Linux常见命令总结

目录 前言 常见命令 ls指令 pwd指令 cd指令 touch指令 tree指令 mkdir指令&&rmdir指令 rm指令 man指令 cp指令 mv指令 echo指令 cat指令&&tac指令 more指令 less指令 head指令&&tail指令 find指令 grep指令 alias指令&&u…

NAT原理(网络地址转换)

NAT原理 网络地址转换&#xff08;Network Address Translation&#xff0c;简称NAT&#xff09; 是一种网络通信协议&#xff0c;它是在网络层上对IP地址进行转换的技术。 NAT技术可以将内部网络中的私有IP地址转换为公共IP地址&#xff0c;以便内部网络中的设备能够访问互…

2023-07-30力扣每日一题

链接&#xff1a; 142. 环形链表 II 题意&#xff1a; 求链表是否有环&#xff0c;并给出入环的点 解&#xff1a; 哈希关联标记或者快慢指针 快慢指针逻辑&#xff1a;设入环前长度a&#xff0c;快慢相遇时指针在b&#xff0c;环长度为c&#xff0c;fast2*slow&#xff…

前端学习--vue2--1-基础配置

写在前面&#xff1a; 好久没写了&#xff0c;做实习每天上班都没啥时间写&#xff0c;1个半月前开始系统学习前端&#xff0c;然后做了半个月主要的前端实习了wk。也行&#xff0c;当复习了&#xff0c;后端也还是搞了点。 本文介绍vue2的一些基础和配置&#xff0c;配置只写…

【C++】——类和对象

目录 面向过程和面向对象的初步认识类的引入类的定义类的访问限定符及封装类的作用域类的实例化this指针类的6个默认成员函数构造函数析构函数 面向过程和面向对象的初步认识 C语言是面向过程的&#xff0c;关注的是过程&#xff0c;分析求解问题的步骤&#xff0c;通过函数调用…

你还不会反射吧,快来吧!!!

首先&#xff1a; 1.加载类&#xff1a; //练习获取字节码对象的3种方式 //Class<Student> studentClass Student.class; //Class<? extends Student> aClass new Student().getClass(); Class<?> clazz Class.forName("TestT.Student"); 2.获…