1 2

【Python】字符串操作

Python可迭代对象遍历

set和string都是可以用 for i in obj:  作遍历的

1 s = 'alexW  Usir%@'
2 for i in s:  # s是可迭代对象
3     if i is not 0: 
4         print(i)

 字符串.split() :把字符串str撕裂

str = 'as@addss@@f'
modified = str.split('@')
print(modified)
print(len(modified[1]))

 

posted @ 2019-04-26 13:05  MasonBox  阅读(96)  评论(0)    收藏  举报