strip函数

f=open('a.txt',)
for l in f.readlines():
  print(l.strip())  # 默认清除字符串l的首尾位的\n或空格,如果是l.strip("a"),则清除l的首尾的a字符(一直清除),返回清楚后的字符串

猜你喜欢

转载自www.cnblogs.com/pjishu/p/10426478.html
今日推荐