import sys
import re
PY_PATTERN = re.compile(
r"""
\s*\#(?:[^\r\n])*
| \s*__(?:[^\r\n]*)
| "{3}(?:\\.|[^\\])*"{3}
| ‘{3}(?:\\.|[^\\])*‘{3}
""",
re.VERBOSE | re.MULTILINE | re.DOTALL
)
txt = open("cmd.txt").readlines()
b = re.sub(PY_PATTERN,‘‘, ‘‘.join(txt))
single = re.compile(r"\n\n")
b = re.sub(single,‘\n‘,b)
print(b)
本文出自 “爱你一万年” 博客,请务必保留此出处http://576642026.blog.51cto.com/1353191/1774712
原文地址:http://576642026.blog.51cto.com/1353191/1774712