Python的应用
李昭仪668
这个作者很懒,什么都没留下…
展开
-
easy_Gui模块游戏
import easygui as gimport syswhile 1:g.msgbox(“嗨,欢迎进入第一个界面的小游戏~~”)msg=“请问你想学到什么小知识呢”title=“小游戏互动”choices=[“棋牌室”,“编程”,“网络安全”,“python”]choice=g.choicebox(msg,title,choices)#note that we convert ...翻译 2019-11-04 19:39:16 · 261 阅读 · 0 评论 -
05——计时器
import time as tclass MyTimer():#开始计时def start(self):self.start=t.localtime()print(“计时开始。。。”)#停止计时def stop(self):self.stop=t.localtime()print(“计时结束。。。”)#内部方法,计算运行时间def _calc(self):self.las...翻译 2019-11-04 19:36:50 · 123 阅读 · 0 评论 -
04_
#class C:def init(self,x=0):self.x=x#c1=C()#print(hasattr(c1,‘x’))#去掉引号是不行的##对象是否有指定的属性hasattr(object,name)#class C:def init(self,x=0):self.x=x#c1=C()##print(hasattr(c1,‘x’))getattr(object,...翻译 2019-11-04 19:35:59 · 110 阅读 · 0 评论 -
03——类
#class C:def x(self):print(“X-man!”)#c=C()#c.x()#c.x=1#print(c.x)#c.x()属性和方法名相同,属性会覆盖方法#class BB:def printBB():print(“no zuo no die”)#BB.printBB()##bb=BB()对象实例化 之后,就不可以调用方法##bb.printBB()...翻译 2019-11-04 19:34:49 · 117 阅读 · 0 评论 -
02——类
class Turtle:def init(self,x):self.num=xclass Fish:def init(self,x):self.num=xclass Pool:def init(self,x,y):self.turtle=Turtle(x)self.fish=Fish(y)def print_num(self):print(“水池里总共有乌龟%d只,小鱼%d...翻译 2019-11-04 19:33:41 · 86 阅读 · 0 评论 -
01——猜数字
import randomsecret=random.randint(1,10)temp=input(“猜一猜数字:”)guess=int(temp)while guess!=secret:temp=input(“猜错了请重新输入吧:”)guess=int(temp)if guess==secret:print(“小蛔虫”)print(“猜对了,没有奖励”)else:if g...翻译 2019-11-04 19:32:44 · 185 阅读 · 0 评论