from easygui import *
import os
def search_file(path):
for root,file_dir,file_list in os.walk(path):
for each_file in file_list:
if os.path.splitext(each_file)[1] == '.py':
py_file.append(os.path.join(root,each_file))
py_file = []
search_path = diropenbox()
search_file(search_path)
def count_line(files,count1):
for i in files:
f = open(i,'rb')
for each_line in f:
count1 += 1
return f'您一共写了{count1}行代码。'
count1 = 0
print(count_line(py_file,count1))
你可能是把 print 写成了这样:from easygui import *
import os
def search_file(path):
for root,file_dir,file_list in os.walk(path):
for each_file in file_list:
if os.path.splitext(each_file)[1] == '.py':
py_file.append(os.path.join(root,each_file))
py_file = []
search_path = diropenbox()
search_file(search_path)
def count_line(files,count1):
for i in files:
f = open(i,'rb')
for each_line in f:
count1 += 1
return f'您一共写了{count1}行代码。'
count1 = 0
count_line(py_file,count1)
print(count1)
|