我是新来的学习者。这个是我写的程序。但似乎有很多问题。我想计算总线条、空白线条、注释线条和代码行。但我不能运行这个程序。我知道我计算评论行的方法是错了。真的吗需要帮助。在
def FileLineCount(filename):
(shotname,extension) = os.path.splitext(filename);
if extension == '.java' : # file type
file = open(filename,'r');
allLines = file.readlines();
file.close();
lineCount =0;
commentCount = 0;
blankCount = 0;
codeCount = 0;
for eachLine in allLines:
if eachLine.find('//'): #LINECOMMENT
commentCount += 1;
else :
if eachLine == "":
blankCount += 1;
else :
codeCount += 1;
lineCount = lineCount + 1;
self.all += lineCount;
self.allComment += commentCount;
self.allBlank += blankCount;
self.allSource += codeCount;
print filename;
print ' Total :',lineCount ;
print ' Comment :',commentCount;
print ' Blank :',blankCount;
print ' Source :',codeCount;
目前没有回答
相关问题 更多 >
编程相关推荐