31个必备的Python字符串方法,建议收藏!
1、Slicing
s = ' hello ' s = s[:] print(s) # hello s = ' hello ' s = s[3:8] print(s) # hello
2、strip()
s = ' hello '.strip() print(s) # hello s = '###hello###'.strip() print(s) # ###hello###
3、lstrip()
s = ' hello '.lstrip()
print(s)
# hello
4、rstrip()
s = ' hello '.rstrip()
print(s)
# hello
https://mp.weixin.qq.com/s/3ebqb72hz4wvBaIP0vk-0A
故乡明

浙公网安备 33010602011771号