马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我的是python 3.5.2 32-bit的
图一是正常状况下的IDLE
图二是一些较为复杂的代码,用IDLE打开之后什么都不显示,连python的基本信息都没显示,并且关不掉,要杀程序才行
图二中的代码我直接双击能正常运行的,我之前也测试过能成功运行的,不知道为什么现在跑的时候只有空白窗口
有大大直到怎么解决吗?感激不尽!!!! import os
import easygui as g
def search_file(start_dir):
total=0
os.chdir(start_dir)
for file in os.listdir(os.curdir):
ext=os.path.splitext(file)[1] #get file extension
if ext =='.py':
print(file)
total=total+ calc_code(file)
else:
pass
return total
def calc_code(file):
lines=0
with open(file) as f:
print('counting the lines')
try:
lines=len(f.readlines())
print(lines)
except UnicodeDecodeError:
print(file+'\n'+'*我不能decode*')
return lines
def show_result(start_dir):
a=search_file(start_dir)
title='result'
msg='您目前共累计编写了【%d】行代码,完成进度:%.2f%%\n \
离10w行代码还差%d行,\
请继续努力!\
' % (a,a/100000,100000-a)
g.textbox(msg,title)
start_dir=g.diropenbox('plz choose ur code bank: ')
show_result(start_dir)
|