|
发表于 2021-11-27 20:29:14
|
显示全部楼层
"""
import easygui as eg
import random
sum=3
x=random.randint(1,11)
y=eg.integerbox("不妨猜一下小甲鱼现在心里想的是那个数字(1-10)","数字小游戏")
while 1:
if y==x:
eg.msgbox(msg="你真棒猜对啦",ok_button="OK([O])")
break
else:
sum -= 1
if sum>0:
eg.msgbox(msg="没关系,下次一定没有问题哒!还有{}次机会".format(sum),ok_button="OK([O])")
y = eg.integerbox("不妨猜一下小甲鱼现在心里想的是那个数字(1-10)", "数字小游戏")
else:
eg.msgbox(msg="没有机会啦,咱们下次再见啦!",ok_button="OK([O])")
break
"""
"""
import easygui as eg
import t2 as t2
s=0
while 1:
x=eg.multpasswordbox(msg="【*真实姓名】为必填项\n【*手机号码】为必填项\n【*E-mail】为必填项\n",title="账号中心",\
fields=["*用户名","*真实姓名","固定电话","*手机号码","QQ","E-mail"])
if x[0]!="" and x[1]!="" and x[3]!="" and x[0][0] != " " and x[1][0]!= " " and x[3][0]!= " ":
break
"""
"""
import easygui as eg
import os
x=eg.fileopenbox(default="*")
with open(x) as f:
eg.textbox(text=f.read(),title="显示文件内容",msg="文件"+"【"+os.path.split(x)[1]+"】"+"的内容如下")
"""
"""
import easygui as eg
import os
os.chdir("C://Users//Acer//Desktop")
x=eg.fileopenbox(default="*")
with open(x) as f:
q=f.read()
t=eg.textbox(text=q,title="显示文件内容",msg="文件"+"【"+os.path.split(x)[1]+"】"+"的内容如下",)
if q!=t:
save=eg.buttonbox(msg="检测到文件内容发生改变",title="警告",choices=["覆盖保存","放弃保存","另存为..."])
if save=="覆盖保存":
with open(x,"w") as f:
f.write(t)
elif save == "另存为...":
pp = eg.filesavebox(default=x)
if ".txt" not in pp:
pp=pp+".txt"
with open(pp,"w") as o:
o.write(t)
"""
# import easygui as eg
# import os
# py=0;v=0;cpp=0;c=0;pas=0;asm=0;
# t=eg.diropenbox()
# x=list(os.walk(t))
# for i in x:
# for j in i[2]:
# if os.path.splitext(j)[1]==".py" or os.path.splitext(j)[1]==".c" or os.path.splitext(j)[1]==".cpp" \
# or os.path.splitext(j)[1]==".pas" or os.path.splitext(j)[1]==".asm":
# try:
# with open(i[0]+"//"+j,encoding="utf-8") as f:
# for n in f:
# if n!="\n":
# if os.path.splitext(j)[1]==".py":
# py+=1
# elif os.path.splitext(j)[1]==".c":
# c+=1
# elif os.path.splitext(j)[1]==".cpp":
# cpp+=1
# elif os.path.splitext(j)[1]==".pas":
# pas+=1
# elif os.path.splitext(j)[1]==".asm":
# asm+=1
# except UnicodeDecodeError:
# try:
# print(i[0]+"//"+j+"\n使用utf-8解不开,尝试用gbk")
# with open(i[0]+"//"+j,encoding="gbk") as f:
# for n in f:
# if n!="\n":
# if os.path.splitext(j)[1] == ".py":
# py += 1
# elif os.path.splitext(j)[1] == ".c":
# c += 1
# elif os.path.splitext(j)[1] == ".cpp":
# cpp += 1
# elif os.path.splitext(j)[1] == ".pas":
# pas += 1
# elif os.path.splitext(j)[1] == ".asm":
# asm += 1
# print("还可以,幸亏解开了,不然我要骂娘了"+"\n")
# except UnicodeDecodeError:
# print("太tm难读了,不读了!下一个!"+"\n")
# continue
# sum=py+cpp+c+pas+asm
# if sum<=10**5:
# bfz=sum/10**3
# dsh=10**5-sum
# eg.textbox(text="【py】敲了{}行\n【c】敲了{}行\n【cpp】敲了{}行\n【pas】敲了{}行\n【asm】敲了{}行\n一共敲了{}行".format(py,c,cpp,pas,asm,sum),\
# msg="你离微软招聘程序员要求代码量还差{:f}%,您还需要打出{}行有效代码,请继续加油!".format(bfz,dsh),title="统计结果")
# else:
# bfz=(sum-10**5)/10**3
# dsh=sum-10**5
# eg.textbox(text="【py】敲了{}行\n【c】敲了{}行\n【cpp】敲了{}行\n【pas】敲了{}行\n【asm】敲了{}行\n一共敲了{}行".format(py, c, cpp, pas, asm,sum), \
# msg="你超过了微软招聘程序员要求代码量的{:f}%,您超过出了{}行有效代码,您是大佬大!!!".format(bfz, dsh), title="统计结果") |
|