c++和Python之rfind不同
2013-01-17 15:17
260 查看
python的string,rfind(str,beg),查找的是从beg开始的子子串中最后出现str的位置, 即从beg位置向后查找
c++的string,rfind(str,beg), 从beg开始向前查找,找到遇到的第一个str的位置
c++
6 6
python
6 6
如果改为s.rfind("||", p1 -1)
c++
6 2
python
6 6
如果改为s.rfind("||", p1 + 1)
c++
6 6
python
6 -1
又犯了一个2B错误,原因是写python多了,把c++ substr(pos, n)认为是substr(from,to)
c++的string,rfind(str,beg), 从beg开始向前查找,找到遇到的第一个str的位置
string s = "12||34||56"; size_t p1 = s.rfind("||"); size_t p2 = s.rfind("||", p1); cout <<p1 <<" "<<p2<<endl; s = '12||34||56' p1 = s.rfind('||') p2 = s.rfind('||',p1) print p1,p2
c++
6 6
python
6 6
如果改为s.rfind("||", p1 -1)
c++
6 2
python
6 6
如果改为s.rfind("||", p1 + 1)
c++
6 6
python
6 -1
又犯了一个2B错误,原因是写python多了,把c++ substr(pos, n)认为是substr(from,to)
相关文章推荐
- Python和C++的不同之处(二)
- C#/C++/Java/Python语言不同手册
- c++和python string 的find()方法的返回值不同
- python与C/C++的不同
- C/C++实战常见错误总结及注意事项【关注与Python的不同点】
- [通用技术]在不同语言中用协程实现全排列算法(C++/Lua/Python/C#)
- 聊一聊Python与C++的不同(二)
- C,C++,python与R,matlab在数组方面的不同
- 聊一聊Python与C++的不同(一)
- Python 学习笔记 (C++与Python的不同)
- 关于java和c++中 i=i++结果不同的分析
- python调用C++编写的DLL
- c++基础:普通变量初始化与类内初始值初始化的不同
- C/C++/Python等 使用二进制模式打开文件与不使用二进制模式的区别
- python36 c++调用python
- Java_语法基础_Java的char与byte--和C++中的是不同的
- c++转python,有些语法就是不一样
- Leetcode_path-sum (updated c++ and python version)
- [Python]linux python解释器路径不同写法的区别