摘要: class Dog(): def _init_(self, name, age): self.name = name self.age=age def sit(self): print(self.name.title()+"is now sitting") def roll_over(self): 阅读全文
posted @ 2017-12-06 21:20 一天一进步 阅读(188) 评论(0) 推荐(0) 编辑
摘要: import类似于c++的include<头文件>,是指复制所有函数到当前模块里面,需要使用导入模块的名字+.函数名 不需要模块的名字+.函数名: from a import b 是指从模块a中导入b函数 from a import b as c 是指把b函数命名为c函数 还可以给模块指定别名 im 阅读全文
posted @ 2017-12-06 16:46 一天一进步 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 函数input()可以让程序暂停执行,等待用户输入后,按回车继续执行。 message = input(”请输入:“) print(message) 通常输入的东西程序会默认其为字符串,若想转化为数字,需要加int函数。 while循环 a=1 while a <=5: break 退出当前循环 c 阅读全文
posted @ 2017-12-06 16:30 一天一进步 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 字典: 是可以存储很多不相关的信息,感觉有点类似于c++的结构体。 people={''name'' :”li nei“,”weight“ :60} 字典是所谓的键—值对应,name是键,linei是值 增加键和值 people["height"]=170 删除键和值 del people[’‘we 阅读全文
posted @ 2017-12-06 08:49 一天一进步 阅读(131) 评论(0) 推荐(0) 编辑