Skip to content

Instantly share code, notes, and snippets.

@robinfang
Last active August 20, 2020 01:00
Show Gist options
  • Save robinfang/abc707e3cbcd2f576cb99576d2e05098 to your computer and use it in GitHub Desktop.
Save robinfang/abc707e3cbcd2f576cb99576d2e05098 to your computer and use it in GitHub Desktop.
检查哪些文件是用的windows换行符。我在用git的时候已经被windows换行符和unix换行符的不同恶心好几次了。
from pathlib import Path
def checkAllPath(allFilePath):
for p in allFilePath:
# print(p)
if p.is_dir():
continue
with open(p, "rb") as f:
content = f.read()
if b"\r\n" in content:
print("windows ending: {}".format(p))
if __name__ == '__main__':
allFilePath = Path('src').rglob('*')
checkAllPath(allFilePath)
allFilePath = Path('public').rglob('*')
checkAllPath(allFilePath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment