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]))

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄