我正在尝试执行以下操作并遇到错误,出了什么问题?
1.根据参数打开目录和子目录中的每个文件
2.检查每个文件的版权信息是否恰好是 3 行
Copyright (c) 2012 Company, Inc.
All Rights Reserved.
Company Confidential and Proprietary.
编码:
import os
import sys
userstring="Copyright (c) 2012 Company, Inc.\nAll Rights Reserved.\nCompany Confidential and Proprietary."
print len(sys.argv)
print sys.argv[1]
if len(sys.argv) < 2:
sys.exit('Usage: python.py <build directory>')
for r,d,f in os.walk(sys.argv[1]):
for files in f:
with open(os.path.join(r, files), "r") as file:
if ''.join(file.readlines()[:3]).strip() != userstring:
print files