Python基础-字符串处理

加密

1 >>> p = str.maketrans("abcdef",'123456')
2 >>> print("alex li".translate(p))
3 1l5x li
View Code

 

提取数字

>>> print('1+2+3+4'.split('+'))
['1', '2', '3', '4']

大小写互换

>>> print('Alex Li'.swapcase())
aLEX lI

posted @ 2017-03-31 16:37  赵东伟  阅读(146)  评论(0)    收藏  举报