摘要: #在Python中其实并没有像C++一样的,private,public,protected这些关键字用来限制访问权限 #但是我们可以在属性和方法的前面加上__双下划先 class testClass(object): def __init__(self): self.__name = "欧米茄" self.score = 100 def __... 阅读全文
posted @ 2017-12-17 22:13 欧晨曦 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 1 #创建一个类,类是一种具有相同属性和方法的抽象 2 #创建类需要使用class关键字,并且定义方法时,方法的第一个参数是self 3 class Student(object): 4 5 #这点与C/C++、C#的语法不同,简单区别下,定义类属性需要在特殊方法__init__内部 6 def __init__(self,name,score): 7 ... 阅读全文
posted @ 2017-12-17 21:29 欧晨曦 阅读(1459) 评论(0) 推荐(0) 编辑
摘要: 1 import os 2 import easygui as g 3 4 def StatisticeCodeLine(dir_name): 5 file_dict = {".py":[0,0],".c":[0,0],".cpp":[0,0],".pas":[0,0],".asm":[0,0]} 6 all_child_dir = os.walk(dir_name... 阅读全文
posted @ 2017-12-17 20:35 欧晨曦 阅读(399) 评论(0) 推荐(0) 编辑
摘要: 1 import random 2 3 secret = random.randint(1,10) #随机一个数字作为答案 4 value = secret + random.randint(100,1000) #随便给一个值,防止重复 5 count = 3 #剩余游戏次数 6 while not secret ... 阅读全文
posted @ 2017-12-17 09:16 欧晨曦 阅读(253) 评论(0) 推荐(0) 编辑