Python的应用
李昭仪668
这个作者很懒,什么都没留下…
展开
-
easy_Gui模块游戏
import easygui as g import sys while 1: g.msgbox(“嗨,欢迎进入第一个界面的小游戏~~”) msg=“请问你想学到什么小知识呢” title=“小游戏互动” choices=[“棋牌室”,“编程”,“网络安全”,“python”] choice=g.choicebox(msg,title,choices) #note that we convert ...翻译 2019-11-04 19:39:16 · 254 阅读 · 0 评论 -
05——计时器
import time as t class 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 · 120 阅读 · 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 · 101 阅读 · 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 · 108 阅读 · 0 评论 -
02——类
class Turtle: def init(self,x): self.num=x class Fish: def init(self,x): self.num=x class 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 · 83 阅读 · 0 评论 -
01——猜数字
import random secret=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 · 182 阅读 · 0 评论