【C++】STL详解之string类

目录

什么是STL

STL的版本

STL的六大组件

STL的缺陷

一.string的定义方式

二. string的插入

1.使用push_back进行尾插

2.使用insert插入

三.string的拼接

四.string的删除

1.使用pop_back进行尾删

2.使用erase进行删除

五.string的查找

1.使用find正向搜索第一个匹配项

2. 使用rfind函数反向搜索第一个匹配项

六.string的比较

七,string的替换

八. string的交换

1.使用swap函数完成两个string类的交换

九. string的大小和容量

1.使用size函数和length函数获取当前有效字符个数

2.使用max_size函数获取对象最多可包含的字符数

3.使用capacity函数获取当前对象所获取的内存空间的的大小

4. 使用resize改变当前对象的有效字符的个数

5.使用reserve改变当前对象的容量大小

6.使用clear删除对象的内容,删除后对象变为空字符串

7.使用empty判断对象是否为空

十. string中元素的访问

1. operator[ ] 

2.使用at访问对象中的元素

3.使用范围for访问对象中的元素

4.使用迭代器访问对象中的元素

十一. string中运算符的使用

1.operator=

2.operator+=

3.operator+

4.operator>> 和 operator<<

5.relational operators(关系运算符)

十二. 与迭代器相关的函数

1.与正向迭代器相关的函数

2.与反向迭代器相关的函数

十三. string与字符串之间的转换

1.将字符串转化为string

2.使用c_str或data转换为字符串

十四.string中子字符串的提取

1.使用substr函数的提取string中的子字符串

2.使用copy函数将string中的子字符串复制到字符数组中

十五. string中的getline函数


本次内容大纲:

什么是STL

STL(standard template libaray-标准模板库):是C++标准库的重要组成部分,不仅是一个可复用的组件库,而且是一个包罗数据结构与算法的软件框架。

STL的版本

原始版本 Alexander Stepanov、Meng Lee 在惠普实验室完成的原始版本,本着开源精神,他们声明允许任何人任意 运用、拷贝、修改、传播、商业使用这些代码,无需付费。唯一的条件就是也需要向原始版本一样做开源使 用。 HP 版本--所有STL实现版本的始祖。

P. J. 版本 由P. J. Plauger开发,继承自HP版本,被Windows Visual C++采用,不能公开或修改,缺陷:可读性比较低, 符号命名比较怪异。

RW版本 由Rouge Wage公司开发,继承自HP版本,被C+ + Builder 采用,不能公开或修改,可读性一般。

SGI版本 由Silicon Graphics Computer Systems,Inc公司开发,继承自HP版 本。被GCC(Linux)采用,可移植性好, 可公开、修改甚至贩卖,从命名风格和编程 风格上看,阅读性非常高。我们后面学习STL要阅读部分源代码, 主要参考的就是这个版本。

STL的六大组件

STL的缺陷

1. STL库的更新太慢了。这个得严重吐槽,上一版靠谱是C++98,中间的C++03基本一些修订。C++11出来已经相隔了13年,STL才进一步更新。

2. STL现在都没有支持线程安全。并发环境下需要我们自己加锁。且锁的粒度是比较大的。

3. STL极度的追求效率,导致内部比较复杂。比如类型萃取,迭代器萃取。

4. STL的使用会有代码膨胀的问题,比如使用vector/vector/vector这样会生成多份代码,当然这是模板语 法本身导致的。

一.string的定义方式

在string类中实现了多个构造函数的重载,常用的构造函数如下:

string(); //构造一个空字符串string (const string& str);	//使用一个已经存在的对象拷贝构造给另一个对象string (const string& str, size_t pos, size_t len = npos); //分割字符串	string (const char* s);	//使用常量字符串实例化一个对象string (const char* s, size_t n); //从第一个元素开始取得向后的元素,限制个数string (size_t n, char c);	//复制C字符,复制n个

string类,构造函数的使用方式:

#include <iostream>
#include <string>
using namespace std;int main() {//实例化一个空字符对象string s7();cout << s7 << endl;//使用常字符串给对象初始化,对象实例化string s1("zyx");cout << s1 << endl;//用一个已经存在的对象给另外一个对象拷贝构造string s2(s1);cout << s2 << endl;//分割字符串string s3("https://cplusplus.com//reference//string//string//string");string s4(s3, 0, 5);string s5(s3, 8, 13);string s6(s3, 23);cout << s4 << endl;cout << s5 << endl;cout << s6 << endl;//从第一个元素开始向后取字符串(第一个参数只能是常量字符串,不能是对象)const char *c1 = "https://cplusplus.com";string s8(c1, 5);cout << s8 << endl;//使用对象会从第五个元素向后取string s9(s3, 5);cout << s9 << endl;//输出"**********"string s10(10, '*');cout << s10 << endl;return 0;
}

二. string的插入

1.使用push_back进行尾插

void push_back (char c)   //在字符串后尾插字符c
//尾插, push_back在string类中是一个成员函数
string s1;
s1.push_back('w');
s1.push_back('x');
s1.push_back('x');
s1.push_back('x');cout << s1 << endl;

2.使用insert插入

string& insert (size_t pos, const string& str);
string& insert (size_t pos, const char* s);
iterator insert (iterator p, char c);
//string类中insert插入的使用
string s0("nxbw");
s0.insert(4, "zyx");
cout << s0 << endl;  //输出:nxbwzyxstring s1 = "FFF";
s0.insert(4, s1);
cout << s0 << endl; //输出:nxbwFFFzyxs0.insert(s0.begin(), 'Z'); //输出:ZnxbwFFFzyx
cout << s0 << endl;

三.string的拼接

string& append (const string& str);
string& append (const char* s);
string& append (size_t n, char c);
string s0("nxbw");
//使用append对string完成拼接
string s2 = "FFF";
//使用的对象进行拼接
cout << s0.append(s2) << endl; //输出:nxbwFFF
//使用字符串进行拼接
cout << s0.append("FF") << endl; //输出:nxbwFFFFFF
//复制字符个数,拼接在对象后面
cout << s0.append(5, 'F') << endl; //输出:nxbwFFFFFFFFFF

四.string的删除

1.使用pop_back进行尾删

void pop_back();
string s0("nxbw");
//使用pop_back进行尾删
s0.pop_back();
s0.pop_back();
s0.pop_back();
cout << s0 << endl; //输出:n

2.使用erase进行删除

string& erase (size_t pos = 0, size_t len = npos);
iterator erase (iterator p);
iterator erase (iterator first, iterator last);
string s0 = "nxbw";
//使用erase删除
s0.erase(0, 2); 
cout << s0 << endl; //输出: bw
//删除某个位置的字符
s0.erase(s0.begin() + 2); 
cout << s0 << endl; //输出nxw
//删除[first, last)这个范围内的字符,左闭右开
s0.erase(s0.begin() + 1, s0.end() - 1);
cout << s0 << endl; //输出:xb

五.string的查找

1.使用find正向搜索第一个匹配项

size_t find (const string& str, size_t pos = 0) const;
size_t find (const char* s, size_t pos = 0) const;
size_t find (char c, size_t pos = 0) const;
//使用find函数正向搜索第一个匹配项
string s1 = "Linux is not NUIX";
string s2 = "is";
//使用string类对象寻找匹配项
size_t count1 = s1.find(s2);
cout << count1 << endl; //输出:6
//使用字符串常量寻找匹配项
const char* str1 = "is";
size_t count1 = s1.find(str1);
cout << count1 << endl; //输出:6
//使用字符串寻找匹配项
const char str2 = 's';
size_t count3 = s1.find(str2);
cout << count3 << endl; //输出:7

2. 使用rfind函数反向搜索第一个匹配项

size_t rfind (const string& str, size_t pos = npos) const;
size_t rfind (const char* s, size_t pos = npos) const;
size_t rfind (char c, size_t pos = npos) const;

可以看到系统跳过了第一个 . 直接寻找的第二个

//使用rfind函数反向搜索第一个匹配项
string s0 = "blog.csdn.net";
string s1 = ".";
//使用string对象进行搜索
size_t count1 = s0.rfind(s1);
cout << count1 << endl; //输出:9
//使用常量字符串进行搜索
const char* str1 = ".";
size_t count2 = s0.rfind(str1);
cout << count2 << endl; //输出:9
//使用字符进行搜索
const char s2 = '.';
size_t count3 = s0.rfind(s2);
cout << count3 << endl; //输出:9

六.string的比较

int compare (const string& str) const;
int compare (size_t pos, size_t len, const string& str) const;
int compare (size_t pos, size_t len, const string& str, size_t subpos, size_t sublen) const;

compare比较规则:

1.从第一个不相同的字符进行比较,如果被比较的字符值较大,或者其他字符都匹配,比较字符串的个数较少,则返回非负数

2.从第一个不相同的字符进行比较,如果被比较的字符值较小,或者其他字符都匹配,比较字符串的个数较多,则返回非正数

3.如果两个字符串每个字符以及个数都相等,则返回0

//比较字符串
string str1 = "stringa";
string str2 = "stringb";
//str1和str2比较
int judge = str1.compare(str2);
cout << judge << endl; //输出:-1 str1小于str2
//切割str1部分与str2比较
judge = str1.compare(0, 5, str2); 
cout << judge << endl; //输出: -1
//切割str1和str2的部分进行比较
judge = str1.compare(0, 4, str2, 0, 4);
cout << judge << endl; //输出: 0 

注:

compare除了可以和string对象比较之外,还可以和字符串进行比较

七,string的替换

使用replace函数完成string的替换

string& replace (size_t pos, size_t len, const char* s);
string& replace (size_t pos, size_t len, size_t n, char c);
//string的替换
string s1 = "hello world";
s1.replace(1, 4, "nxbw");
cout << s1 << endl; //输出:hnxbw world
//replace(pos, len, n, c)
//从pos位置开始往后len个位置,替换为n个字符c
s1.replace(11, 3, 3, '!');
cout << s1 << endl; //输出: hnxbw world!!!

八. string的交换

1.使用swap函数完成两个string类的交换

void swap (string& x, string& y);
void swap (string& str);
//swap交换
string s1 = "nxbw";
string s2 = "wxxx";swap(s1, s2);
cout << s1 << ' ' << s2 << endl; //输出:wxxx nxbws1.swap(s2);
cout << s1 << ' ' << s2 << endl; //输出:nxbw wxxx

九. string的大小和容量

1.使用size函数和length函数获取当前有效字符个数

size_t size() const;
size_t length() const;
//使用函数获取该对象当前有效字符个数
string s1("I love learning");cout << s1.size() << endl; //输出:15
cout << s1.length() << endl; //输出:15

算大小,这里推荐使用size,当热你想使用length也可以

2.使用max_size函数获取对象最多可包含的字符数

size_t max_size() const;
string s1("I love learning");
cout << s1.max_size() << endl; //输出: 2147483647

3.使用capacity函数获取当前对象所获取的内存空间的的大小

size_t capacity() const;
//获取容量
string s1 = "nxbw";
cout << s1.capacity() << endl; //输出: 15

4. 使用resize改变当前对象的有效字符的个数

void resize (size_t n);
void resize (size_t n, char c);

resize使用规则

1. 当n大于size时,将size扩大到n,扩大的字符为c,若c未给出,则默认为’\0‘

2. 当n小于size时,将size缩小到n

//改变对象当前有效字符的数量
string s1("hello world");
//扩大该对象有效字符的个数,扩大的部分默认为:'\0'
s1.resize(20);
cout << s1 << endl; //hello world
cout << s1.size() << endl; //20
cout << s1.capacity() << endl; //31//扩大该对象有效字符的个数,扩大的部分为:'x'
s1.resize(30, 'x');
cout << s1 << endl; // hello worldxxxxxxxxxx
cout << s1.size() << endl; //30
cout << s1.capacity() << endl; //31//缩小该对象有效字符个数
s1.resize(5);
cout << s1 << endl; //输出:hello
cout << s1.size() << endl; //5
cout << s1.capacity() << endl; //31 

5.使用reserve改变当前对象的容量大小

void reserve (size_t n = 0);
//改变当前对象容量大小
string s1("hello");
//缩小该对象的容量,对象的容量不会改变
s1.reserve(20);
cout << s1 << endl; //hello
cout << s1.size() << endl; //5
cout << s1.capacity() << endl; //31
//增大该对象的容量,将当前对象的capacity扩大到n或者大于n
s1.reserve(40);
cout << s1 << endl; //hello
cout << s1.size() << endl; //5
cout << s1.capacity() << endl; //47

6.使用clear删除对象的内容,删除后对象变为空字符串

void clear();
//删除某个对象的内容,删除后变成空字符串
string s1 = "csdn";
s1.clear();
cout << s1 << endl;

7.使用empty判断对象是否为空

bool empty() const;

判定规则:

对象不为空,返回1

对象为空,返回0

//判断是否为空
string s1("nxbw");
cout << s1.empty() << endl; // 0//删除之后在判断
s1.clear();
cout << s1.empty() << endl; // 1

十. string中元素的访问

1. operator[ ] 

因为string类对[ ]运算符进行了重载,所以我们可以使用[ ]+下标的方式来访问对象中的元素。并且该重载使用的是引用返回,所以我们可以通过下标加[ ]的方式改修对应位置的元素

char& operator[] (size_t pos);
const char& operator[] (size_t pos) const;
//operator[]
string s1("hello world");cout << s1.size() << endl; //11
int i = 0;
//使用operator[]打印出s1的内容
for (i = 0; i < s1.size(); ++i)
{//没有打印出'\0',因为size函数计算不包含('\0')cout << s1[i];  //hello world
}
cout << endl;//[]+下标来修改对应对象元素内容
int j = 0;
for (j = 0; j < s1.size(); ++j)
{s1[j]++;cout << s1[j]; //ifmmp!xpsme
}
cout << endl;

2.使用at访问对象中的元素

char& at (size_t pos);
const char& at (size_t pos) const;
//使用at对s1进行访问
string s1("hello world");cout << s1.size() << endl; //11
int i = 0;
//使用at访问s1打印出s1的内容
for (i = 0; i < s1.size(); ++i)
{//没有打印出'\0',因为size函数计算不包含('\0')cout << s1.at(i);  //hello world
}
cout << endl;//通过at来修改对应对象元素内容
int j = 0;
for (j = 0; j < s1.size(); ++j)
{s1.at(j)++;cout << s1.at(j); //ifmmp!xpsme
}
cout << endl;

3.使用范围for访问对象中的元素

使用该语法,需要特别注意的是,如果你需要使用范围for来修改对象的元素,那么接收元素的变量必须是引用类型,否则e只是该对象元素的一个拷贝,修改e不会对对象元素有任何影响

//使用范围for来访问s1元素
string s1("nxbw,zswdmb");
for (auto e : s1)
{cout << e;//nxbw,zswdmb
}
cout << endl;
//使用范围for修改s1对应元素
for (auto& e : s1) //注意想要修改元素e的类型必须引用
{e++;cout << e;//oycx-{txenc
}
cout << endl;

auto可以是其他类型。范围for底层实现就是用迭代器实现的,一个类只要支持迭代器他就支持范围for

可以通过汇编看到

4.使用迭代器访问对象中的元素

迭代器的使用方式:容器<类型>::iterator 变量名 (迭代器的用法和指针类似)

//使用迭代器访问对象元素,并对其进行修改
string s1 = "nxbw";
string::iterator it = s1.begin();
for (int i = 0; i < s1.size(); ++i)
{cout << (*it); //nxbwit++;
}
it = s1.begin();
cout << endl;
//使用迭代器访问修改对应元素
for (int i = 0; i < s1.size(); ++i)
{(*it)++;cout << (*it); //oycxit++;
}
cout << endl;

迭代器:

iterator提供一种统一的方式修改和访问容器的数据

迭代器可以和算法配合来对访问容器中的数据进行操作

例:

vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);vector<int>::iterator it = v.begin();
for (auto e : v)
{cout << e << ' '; //1 2 3 4
}
cout << endl;
//迭代器通过和算法配合可以对容器中的数据进行操作
reverse(v.begin(), v.end());
for (auto e : v)
{cout << e << ' '; //4 3 2 1
}
cout << endl;

十一. string中运算符的使用

1.operator=

string中对=运算符进行重载,重载后的=运算度支持string类的赋值,字符串的赋值以及字符的赋值

//使用operator=
string s1("nxbw");
string s2;//支持对象之间的赋值
s2 = s1;
cout << s2 << endl; //nxbw
//支持字符串赋值给对象
s2 = "csdn";
cout << s2 << endl; //csdn
//支持字符赋值给对象
s2 = 'z';
cout << s2 << endl; //zyx

2.operator+=

string类中对+=运算符进行了重载,重载后的+=运算符支持string类的复合赋值,字符串的复合赋值,字符的复合赋值

//使用operator+=
string s1("n");
string s2("x");//支持对象之间的赋值
s1 += s2;
cout << s1 << endl; //nx
//支持字符串赋值给对象
s1 += "bw";
cout << s1 << endl; //nxbw
//支持字符赋值给对象
s1 += '!';
cout << s1 << endl; //nxbw!

3.operator+

string类中支持+运算符的重载,重载之后支持以下几种操作:

string类 + string类   string类 + 字符串   字符串 + string类

string类 + 字符   字符 + string类

//operator+
string s1("nxbw");
string s2("!wxxx");
string s3;
//string类 + string类
s3 = s1 + s2;
cout << s3 << endl; //nxbw!wxxx
//string类 + 字符串
s3 = s1 + "!wxxx";
cout << s3 << endl; //nxbw!wxxx
//字符串 + string类
s3 = "nxbw" + s2;
cout << s3 << endl; //nxbw!wxxx
//string类 + 字符 
s3 = s1 + '!';
cout << s3 << endl; //nxbw!
//字符 + string类
s3 = '!' + s1;
cout << s3 << endl; //nxbw!

4.operator>> 和 operator<<

string类中也重载了<<和>>运算符,正是如此,我们才能直接对string类对象进行输入和输出

//operator<<和opeartor>>
string s1;
cin >> s1;
cout << s1 << endl;	

5.relational operators(关系运算符)

string中还对一些关系运算符继续了重载,它们分别是:==,!=, <, <=, >, >=,这些运算符都支持string类和string类,string类和字符串,。string类和字符

//关系运算符
string s1("nxbw");
string s2("wxxx");cout << (s1 > s2) << endl; //0
cout << (s1 >= s2) << endl; //0
cout << (s1 < s2) << endl; //1
cout << (s1 <= s2) << endl; //1
cout << (s1 == s2) << endl; //0
cout << (s1 != s2) << endl; //1

注:与C比较方法一样,都是比较的AscII码值

十二. 与迭代器相关的函数

1.与正向迭代器相关的函数

begin:返回一个指向字符串第一个字符迭代器

iterator begin();
const_iterator begin() const;

end:返回一个指向字符串结束字符的迭代器,即:最后一字符的后面一位 

iterator end();
const_iterator end() const;

以下图为例:

//使用迭代器访问对象元素,并对其进行修改
string s1 = "nxbw";
string::iterator it = s1.begin();
while(it != s1.end())
{cout << (*it); //nxbwit++;
}
cout << endl;

2.与反向迭代器相关的函数

rbegin函数:返回指向一个字符串最后一个字符的反向迭代器

reverse_iterator rbegin();
const_reverse_iterator rbegin() const;

rend函数:返回指向一个字符串第一个字符的前面的反向迭代器

reverse_iterator rend();
const_reverse_iterator rend() const;

如图:

//反向迭代器的使用
string s1("nxbw");
string::reverse_iterator rit = s1.rbegin();
while (rit != s1.rend())
{cout << *rit; //wbxnrit++;
}
cout << endl;

觉得类型太长,也可以使用auto帮你自动识别类型

//反向迭代器的使用
string s1("nxbw");
auto rit = s1.rbegin();
while (rit != s1.rend())
{cout << *rit; //wbxnrit++;
}
cout << endl;

例:

为了避免权限扩大,这里只能使用方向迭代器:const_reverse_iterator,觉得类型很长可以使用auto自动识别类型,

//翻转
void Func(const string& s1) //s1是nxbw
{string::const_reverse_iterator rit = s1.rbegin();/*for(auto e : s1)*/while(rit != s1.rend()){cout << *rit; //wbxn++rit;}cout << endl;
}

十三. string与字符串之间的转换

1.将字符串转化为string

//将字符串转化为string类
string s1("hello world");
cout << s1 << endl; //hello worldchar str[] = "hello world";
string s2(str);
cout << s2 << endl; //hello world

2.使用c_str或data转换为字符串

const char* c_str() const;
const char* data() const;
  • 在C++98中,c_str()返回 const char* 类型,返回的字符串会以空字符结尾。
  • 在C++98中,data()返回 const char* 类型,返回的字符串不以空字符结尾。
  • 但是在C++11版本中,c_str()与data()用法相同。
//将string类对象转换为字符串
string s1("hello world");const char* str1 = s1.c_str();
const char* str2 = s1.data();cout << str1 << endl; //hello world
cout << str2 << endl; //hello world

十四.string中子字符串的提取

1.使用substr函数的提取string中的子字符串

string substr (size_t pos = 0, size_t len = npos) const;
//提取string中的字符串
string s1("nxbw");
string s2;s2 = s1.substr(2, 3);
cout << s2 << endl; //bw

2.使用copy函数将string中的子字符串复制到字符数组中

size_t copy (char* s, size_t len, size_t pos = 0) const;
//使用copy函数将string中的子字符串拷贝到字符数组中
string s1("nxbw");
char str1[20];//copy函数不会帮你在末尾加'\0',所以得手动添加'\0'
size_t length = s1.copy(str1, 4, 0);
str1[length] = '\0';
cout << str1 << endl; //nxbw

十五. string中的getline函数

使用>>(流提取操作符)进行输入操作,当>>读取到空格时就会停止读取,我们不能使用>>将一串含有空格的字符串输入到string对象中

例:

空格cin完全读取不到

string s1;cin >> s1; //hello world
cout << s1 << endl; //hello

遇到空格就停止读取,怎么办呢?这时就需要使用getline函数

使用方法一:

istream& getline (istream& is, string& str);
//使用getline往string中输入
string s1;
getline(cin, s1);
cout << s1 << endl; //hello world

使用方法二:

istream& getline (istream& is, string& str, char delim);
//使用getline往string中输入
string s1;
getline(cin, s1, 'b'); //第三个参数是读取结束标志或者换行符(\n)为止
cout << s1 << endl; //nx

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

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

相关文章

快速排序(plus)与单调栈道,力扣912.排序数组​​​​​​​力扣215.数组中的第k大个元素力扣17.14最小的k个数单调栈力扣.柱状图中最大的矩形

目录 力扣912.排序数组​​​​​​​ 力扣215.数组中的第k大个元素 力扣17.14最小的k个数 单调栈 力扣.柱状图中最大的矩形 力扣912.排序数组 快速排序:最重要的就是数据划分&#xff0c;叫做partation left往后走&#xff0c;假如遇到比key小的&#xff0c;left是因为&a…

解释器模式原理剖析和Spring中的应用

解释器模式原理剖析和Spring中的应用 解释器模式 是一种行为型设计模式&#xff0c;它定义了一种语言的文法表示&#xff0c;并提供了一个解释器来处理该文法的表达式。解释器模式可以用于构建语法解释器&#xff0c;例如计算器、简单编程语言的解释器等。 核心思想&#xff1a…

My_String完善

#include "my_string_ok.h" My_string_Ok::My_string_Ok():size(20) { len 0; ptr new char[size]; ptr[len] \0; } My_string_Ok::My_string_Ok(int num,char c) { cout<<"有参构造"<<endl; ptr new char [20] ; len 0; for…

深度学习技术在超材料科学中的应用与实操

人工智能算法赋能材料设计与应用专题培训 前沿背景 人工智能与材料科学的融合趋势&#xff1a;在材料科学领域&#xff0c;人工智能&#xff08;AI&#xff09;的引入正在引发一场革命。传统的材料设计和优化依赖于经验和试错方法&#xff0c;这不仅耗时且成本高昂。关于AI赋…

安科瑞Acrel-1000DP分布式光伏监控系统在鄂尔多斯市鄂托克旗巴音乌苏六保煤矿5MW分布式光伏项目中的应用

安科瑞 华楠 摘 要&#xff1a;分布式光伏发电就是将太阳能光伏板分散布置在各个区域&#xff0c;通过小规模、模块化的方式实现电能的并网或独立使用&#xff0c;这种发电方式具有就近发电、就近并网、就近转换、就近使用的特点。近年来&#xff0c;技术进步和政策支持推动了光…

Python批量合并365个工作表的2种方法

一、引言 小明刚进入到新公司&#xff0c;就被委以重任&#xff1a;将365个Excel文件中的英文表头修改为中文。传统方法是逐一打开每个文件&#xff0c;手动修改标题&#xff0c;然后保存&#xff0c;最后再合并。这种方法不仅耗时耗力&#xff0c;还容易出错。如果用Python就…

下水道内缺陷识别检测数据集 yolo数据集 共2300张

下水道内缺陷识别检测数据集 yolo数据集 共2300张 下水道内部缺陷识别数据集&#xff08;Sewer Interior Defect Recognition Dataset, SIDRD&#xff09; 摘要 SIDRD 是一个专门针对下水道内部缺陷识别的数据集&#xff0c;旨在为城市基础设施维护和管理提供一个标准化的训练…

Qt:关于16进制数转化那些事

前言 由于当时做UDP通信的时候使用16进制数与QString的相互转换&#xff0c;但是当时我所要求的转换不仅仅是转化过去就行了&#xff0c;我还有字节数要求&#xff0c;就是这个16进制数占据多少位那么转化后的数据就该占据多大的空间。 正文 1 将 QString 转换为16进制字符串…

【Redis入门到精通五】Java如何像使用MySQL一样使用Redis(jedis安装及使用)

目录 Jedis 1.jedis是什么 2.jedis的安装配置 3.jedis的基础命令操作展示 1.set和get操作&#xff1a; 2.exists和del操作&#xff1a; 3.keys和type操作&#xff1a; 4. expire和ttl&#xff1a; Jedis Java 操作 redis 的客⼾端有很多&#xff0c;其中最知名的是 jedi…

STM32基础学习笔记-Timer定时器面试基础题5

第五章、TIMER 常见问题 1、基本概念&#xff1a;什么是定时器 &#xff1f;作用 &#xff1f;分类 &#xff1f; 2、时基单元 &#xff1f;组成 &#xff1f;计数模式 &#xff1f;溢出条件 &#xff1f; 溢出时间计算 &#xff1f; 3、systick原理 &#xff1f;代码讲解 &…

中国蚁剑(antSword)安装使用

antSword下载 antSword-Loader下载 作者&#xff1a;程序那点事儿 日期&#xff1a;2024/09/12 19:35 中国蚁剑&#xff08;AntSword&#xff09;是一款跨平台的开源网站管理工具&#xff0c;旨在满足渗透测试人员的需求。它是一个功能强大的工具&#xff0c;可以帮助用户管理…

基于CPS CPSQ5453CPSQ5352的易冲车灯方案

一、方案描述 CPS易冲&#xff08;CONVENIENTPOWER&#xff09;针对汽车矩阵大灯&#xff0c;推出 基于CPS CPSQ5453 & CPSQ5352的汽车矩阵式大灯方案。 开发板搭载的主要器件有CPS的独立双通道恒压恒流升压控制器&#xff1a;CPSQ5453、独立双通道LED恒流降压变换器&#…

心觉:如何重塑高效学习的潜意识(1)两种方法的优缺点

Hi&#xff0c;我是心觉&#xff0c;与你一起玩转潜意识、脑波音乐和吸引力法则&#xff0c;轻松掌控自己的人生&#xff01; 挑战每日一省写作180/1000天 你的学习习惯是什么呢 学习的时候是感到轻松吗 很多人感觉现在是知识大爆炸的时代&#xff0c;每天都会产生海量的知…

第 1 章:Vue 核心

1. Vue 简介 1.1. 官网 英文官网: https://vuejs.org/中文官网: https://cn.vuejs.org/&#xff1a;中文官网里面【教程】和【API】是比较重要的。用到api就去查询&#xff0c;实践当中记忆更牢靠。 风格指南&#xff1a;官方推荐写的一个代码风格cookbook&#xff1a;编写v…

【Python报错已解决】SyntaxError: invalid syntax

&#x1f3ac; 鸽芷咕&#xff1a;个人主页 &#x1f525; 个人专栏: 《C干货基地》《粉丝福利》 ⛺️生活的理想&#xff0c;就是为了理想的生活! 专栏介绍 在软件开发和日常使用中&#xff0c;BUG是不可避免的。本专栏致力于为广大开发者和技术爱好者提供一个关于BUG解决的经…

计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-09-25

计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-09-25 1. PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs) M Nazzal, I Khalil, A Khreishah, NH Phan - arXiv preprint arXiv:2409.12699, 2…

车辆识别数据集,图片数量20500,模型已训练200轮

车辆识别数据集&#xff08;Vehicle Recognition Dataset, VDRD&#xff09; 摘要 VDRD 是一个专为车辆识别设计的大规模数据集&#xff0c;它包含了20500张不同类型的汽车、货车、公交车以及其他类型车辆的图像。数据集提供了四种车辆类别&#xff1a;汽车、货车、其他车辆和…

网页爬虫法律与道德:探索法律边界与道德规范

目录 引言 一、网络爬虫技术概述 1.1 定义与功能 1.2 技术原理 1.3 案例分析 二、网络爬虫的法律边界 2.1 合法性要求 2.2 刑事风险 2.3 案例分析 三、网络爬虫的道德规范 3.1 尊重版权和隐私 3.2 合理使用爬虫技术 3.3 透明度和社会责任 四、技术挑战与应对策略…

支付宝沙箱环境 支付

一 什么是沙箱&#xff1a; 沙箱环境是支付宝开放平台为开发者提供的安全低门槛的测试环境 支付宝正式和沙箱环境的区别 &#xff1a; AI&#xff1a; 从沙箱到正式环境&#xff1a; 当应用程序开发完成后&#xff0c;需要将应用程序从沙箱环境迁移到正式环境。 这通常涉及…

RabbitMQ——消息的可靠性处理

1.业务分析 在业务的开发中&#xff0c;我们通常将业务的非核心业务交给MQ来处理&#xff0c;比如支付&#xff0c;在支付过后&#xff0c;我们需要扣减余额&#xff0c;修改支付单状态&#xff0c;修改订单状态&#xff0c;发送短信提醒用户&#xff0c;给用户增加积分等等&am…