# 方法一s = ' abc 123 'print s.strip() # 去掉两端的空格print s.lstrip() # 去掉左端的空格print s.rstrip() # 去掉右端的空格s = '---abc+++'print s.strip('-+') # abc# 方法二s = 'abc:123'print s[:3] + s[4:] # abc1
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号