37,743
社区成员
发帖
与我相关
我的任务
分享

import os
count = 0
def search_file(url):
os.chdir(url)
global count
for file_dir in os.listdir(os.path.curdir):
print(os.path.isfile(file_dir))
if os.path.isfile(file_dir):
ext = os.path.splitext(file_dir)[1]
if ext == '.py':
with open(file_dir) as f:
for each in f:
count += 1
elif os.path.isdir(file_dir):
search_file(file_dir)
os.path.pardir
url = input('输入地址:')
search_file(url)
print(count)