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