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)]
本文提供了一种处理文本文件new_DMS.txt的方法,通过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)]
4789
1825
1万+

被折叠的 条评论
为什么被折叠?
