
python
梦中一夜下江南
现在南通的一家技术公司的技术负责人,目前专注于客户端开发。
展开
-
Python学习笔记06-类与文件和异常
面向对象编程 创建和使用类,dog.pyclass Dog(): """一次模拟小狗的简单尝试""" def __init__(self, name, age): #其它语言的构造方法 """初始化属性name和age""" self.name = name self.age = age def sit(self):原创 2017-06-04 17:29:30 · 1228 阅读 · 0 评论 -
Python学习笔记01
用的是3.6.1 以py结尾的文件变量不需要声明 num = 23不需要;结尾 strs = “i am a string” float = 2.3 bool = true字符串的连接 +号类型转换 str(2) 转字符串 int(“20140701”) 转int 其它类型类似去空格方法 rstrip() ri原创 2017-06-02 17:55:48 · 243 阅读 · 0 评论 -
Python学习笔记02-列表与操作列表
列表相当于其他语言里的数组 bicycles = [‘book01’,’book02’,’book03’,’book04’] 单引号与双引号没什么关系访问列表元素 bicycles[0]通过下标 title() 首字母大写修改列表 bicycles[0] = ‘bok01’//修改 bicycles.append(‘book05’) //添加 bi原创 2017-06-02 20:26:09 · 489 阅读 · 0 评论 -
Python学习笔记03-if语句
cars = 'times'cars == 'times'trueif cars != 'aa': print('cars')&& == and| == orrequested_toppings = ['mushrooms','onions','pineapple']if 'mushrooms' in requested_toppings : trueage = 19if原创 2017-06-04 09:46:34 · 456 阅读 · 0 评论 -
Python学习笔记04-字典和用户输入和 while 循环
一个简单的字典alien = {'color': 'green', 'points': 5}print(alien['color'])print(alien['points'])green5增加字典alien['animal'] = 'dog'创建一个空字典alien_0 = {}alien_0['color'] = 'green'alien_0['points'] = 5print(原创 2017-06-04 10:47:03 · 1701 阅读 · 0 评论 -
Python学习笔记05-函 数
定义函数def greet_user(): """显示简单的问候语""" print("Hello!")greet_user()向函数传递信息def greet_user(username): """ 显示简单的问候语 """ print("Hello, " + username.title() + "!") greet_user('jesse')Hello, J原创 2017-06-04 15:44:47 · 994 阅读 · 0 评论