我正在尝试执行以下操作,即使是一个很好的案例,示例输入文件和完整代码都无法匹配,下面给出了完整的代码?为什么代码与下面的示例输入文件不匹配?如何克服它?
1.根据参数打开目录和子目录中的每个文件(which
2.检查每个文件的版权信息是否正好是3行,这3行不必是3行开头
Copyright (c) 2012 Company, Inc.
All Rights Reserved.
Company Confidential and Proprietary.
示例输入文件:-
File1.txt
/*==========================================================================
*
* @file: Compiler.h
*
* @brief: This file
*
*
* @author: david
*
* Copyright (c) 2012 Company, Inc.
* All Rights Reserved.
* Company Confidential and Proprietary
*
*=========================================================================*/
#ifndef __COMPILER_ABSTRACT_H
#define __COMPILER_ABSTRACT_H
编码:
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