C++标准库中字符串转数值使用函数atoi(),数值转字符串使用printf系列函数. boost中使用转换函数操作符lexical_cast<>进行转换,实际上是模板函数.自定义类型,要进行转换必须支持输入输出操作符<< >>. #include <iostream> #include <boost/lexical_cast.hpp> using namespace std; using namespace boost; int main()…
13.如何拆分含有多种分隔符的字符串 import re s = "23:41:2314\1234#sdf\23;" print(re.split(r'[#:\;]+',s)) 14.如何判断字符串a是否以字符串b开头或结尾 import os,stat #找到当前目录下的文件名称,返回list ret = os.listdir('.') print(ret) for x in ret: #endswith传参类型是tuple if x.endswith(('.py','.html'…