2020年1月13日

Python中random模块的用法案例

摘要: 1 import random # 调用random模块 2 3 a = random.random() # 随机从0-1之间抽取一个小数 4 print(a) 5 6 a = random.randint(0,100) # 随机从0-100之间抽取一个数字 7 print(a) 8 9 a = r 阅读全文

posted @ 2020-01-13 17:01 Through-Target 阅读(395) 评论(0) 推荐(0) 编辑

Python中模块import的使用案例

摘要: 1 import test # 导入test模块 2 3 print(test.a) # 使用“模块.变量”调用模块中的变量 4 5 test.hi() # 使用“模块.函数()”调用模块中的函数 6 7 A = test.Go2() # 使用“变量 = 模块.类()”实例化模块中的类 8 prin 阅读全文

posted @ 2020-01-13 11:51 Through-Target 阅读(520) 评论(0) 推荐(0) 编辑

Python中模块的定义及案例

摘要: 1 a = '我是模块中的变量a' 2 3 def hi(): 4 a = '我是函数里的变量a' 5 print('函数“hi”已经运行!') 6 7 class Go2: 8 a = '我是类2中的变量a' 9 def do2(self): 10 print('函数“do2”已经运行!') 11 阅读全文

posted @ 2020-01-13 11:33 Through-Target 阅读(311) 评论(0) 推荐(0) 编辑

导航