Discuss / Python / 冲!

冲!

Topic source

v贝塔v

#1 Created at ... [Delete] [Delete and Lock User]

看榜一原来切片s[:1]还可以等效len()的作用啊,nb

def trim(s):
	while(len(s) and s[0] == ' '):
		s = s[1:]
	while(len(s) and s[-1] == ' '):	
		s = s[:-1]
	print(s)
	return s

  • 1

Reply