C++可用substr取子串:
例如:
string s="dlkjsldfjlsfjslfdjk";
string st=s.substr(4,5);
4表示从索引为4的字符开始,5表示子串的个数
s索引为4的字符是's',因此st="sldfj"
python:
st=s[4:9]
从索引为4的字符到索引为9的字符,不包括9
结果如下:
C++可用substr取子串:
例如:
string s="dlkjsldfjlsfjslfdjk";
string st=s.substr(4,5);
4表示从索引为4的字符开始,5表示子串的个数
s索引为4的字符是's',因此st="sldfj"
python:
st=s[4:9]
从索引为4的字符到索引为9的字符,不包括9
结果如下: