长风破浪会有时,直挂云帆济沧海

Dream Word

博客园 首页 新随笔 联系 订阅 管理

2017年12月24日 #

摘要: chapter8 函数 8.6 将函数存储在模块中 8.6.1 导入整个模块 要让函数是可导入的,的先创建模块。模块 的扩展名为.py的文件 import pizza 8.6.2 到导入特定的函数 from module_name import function_name fromt module_ 阅读全文
posted @ 2017-12-24 23:24 长风II 阅读(221) 评论(0) 推荐(1) 编辑

摘要: chapter9 类 9.1 创建和使用类 9.1.1 创建Dog类 class Dog(): """一次模拟小狗的简单尝试""" def _init_(self, name, age): self.name = name self.age = age def sit(self): print(se 阅读全文
posted @ 2017-12-24 23:24 长风II 阅读(448) 评论(0) 推荐(1) 编辑

摘要: chapter10 文件和异常 10.1 从文件中读取数据 10.1.1 读取整个文件 with open("pi.txt") as file_object: contents = file_object.read() print(contents) print(contents.rstrip()) 阅读全文
posted @ 2017-12-24 23:24 长风II 阅读(221) 评论(0) 推荐(0) 编辑

摘要: chapter6 字典 6.1 一个简单的字典 6.2 使用字典 6.2.1 访问字典中的值 6.2.2 添加键值对 6.2.3 先创建一个空字典 6.2.4 修改字典中的值 6.2.5 删除键值对 del alien['points'] 6.2.6 由类似对象组成的字典 favorite_lang 阅读全文
posted @ 2017-12-24 23:23 长风II 阅读(157) 评论(0) 推荐(0) 编辑

摘要: chapter5 if语句5.1 一个简单示例cars = ['audio','bmw','subaru','toyota'] for car in cars:if car == 'bmw':print(car.upper())else:print(car.title())5.2 条件测试5.2.1 阅读全文
posted @ 2017-12-24 23:22 长风II 阅读(201) 评论(0) 推荐(0) 编辑