#format:
>>> name="lijj"
>>> print("my name is",name)
my name is lijj
>>> i=10
>>> print("i=",bin(i))
i= 0b1010
#find
>>> "xxxxx7".find('7')
5
#join
>>> sep='+'
>>> seq=["1","2","3","4","5"]
>>> sep.join(seq)
'1+2+3+4+5'
>>> dirs=['',"usr",'bin']
>>> '/'.join(dirs)
'/usr/bin'
#lower
>>> low="xxxxeeewwwwwsssSSSS"
>>> low.lower()
'xxxxeeewwwwwsssssss'
#upper
>>> low.upper()
'XXXXEEEWWWWWSSSSSSS'
#split
>>> '1+2+3'.split('+')
['1', '2', '3']
>>> '/usr/bin/env'.split('/')
['', 'usr', 'bin', 'env']
#strip
>>> " join".strip()
'join'
Python之字符串
最新推荐文章于 2022-09-08 14:39:55 发布