Python 去除文本中空白和换行

print [x.strip() for x in open('new_DMS.txt').readlines() if not re.search(r'^\s+$',x)]

print [x.strip() for x in open('new_DMS.txt') if not re.search(r'^\s+$',x)]

猜你喜欢

转载自scm002.iteye.com/blog/2250710
今日推荐