Python字符串操作
上一篇 /
下一篇 2013-12-06 09:40:41
s.strip() .lstrip() .rstrip(',') 去空格及特殊符号
复制字符串
Python
连接字符串
Python
查找字符
< 0 未找到
Python
4 | nPos = sStr1.index(sStr2) |
比较字符串
Python
扫描字符串是否包含指定的字符
Python
5 | print len (sStr1 and sStr2) |
字符串长度
Python
将字符串中的大小写转换
Python
追加指定长度的字符串
Python
字符串指定长度比较
Python
5 | print cmp (sStr1[ 0 :n],sStr2[ 0 :n]) |
复制指定长度的字符
Python
将字符串前n个字符替换为指定的字符
Python
5 | sStr1 = n * ch + sStr1[ 3 :] |
扫描字符串
Python
翻转字符串
Python
查找字符串
Python
分割字符串
Python
2 | sStr1 = 'ab,cde,fgh,ijk' |
4 | sStr1 = sStr1[sStr1.find(sStr2) + 1 :] |
连接字符串
Python
2 | mylist = [ 'Brazil' , 'Russia' , 'India' , 'China' ] |
3 | print delimiter.join(mylist) |
PHP 中 addslashes 的实现
Python
2 | d = { '"' : '\\"' , " '":"\\' ", " \ 0 ":" \\\ 0 ", " \\ ":" \\\\"} |
3 | return ''.join(d.get(c, c) for c in s) |
5 | s = "John 'Johny' Doe (a.k.a. \"Super Joe\")\\\0" |
只显示字母与数字
Python
1 | def OnlyCharNum(s,oth = ''): |
3 | fomart = 'abcdefghijklmnopqrstuvwxyz0123456789' |
9 | print (OnlyStr( "a000 aa-b" )) |
收藏
举报
TAG: