摘要: # readlines() read() with open('pi_digits.txt') as file_object: #函数open()接受一个参数:要打开的文件的名称。 contents = file_object.read() print(contents) print(content 阅读全文
posted @ 2019-02-27 23:30 波波皮球 阅读(90) 评论(0) 推荐(0) 编辑
摘要: class Car(): """一次模拟汽车的简单尝试""" def __init__(self, make, model, year): self.make = make self.model = model self.year = year self.odometer_reading = 0 d 阅读全文
posted @ 2019-02-26 23:33 波波皮球 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1 # 练习9-1 2 """9-1 餐馆 :创建一个名为Restaurant 的类,其方法__init__() 设置两个属性:restaurant_name 和cuisine_type 。创建一个名 3 为describe_restaurant() 的方法和一个名为open_restaurant( 阅读全文
posted @ 2019-02-26 00:21 波波皮球 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 1 # 传递任意数量的实参 2 def make_pizza(size, *toppings): # 重点 必须在函数定义中将接纳任意数量实参的形参放在最后 3 """概述要制作的比萨""" 4 print("\nMaking a " + str(size) + 5 "-inch pizza with the followin... 阅读全文
posted @ 2019-02-25 18:48 波波皮球 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1 8.2.3 2 def describe_pet(pet_name, animal_type='dog'): 3 """显示宠物的信息""" 4 print("\nI have a " + animal_type + ".") 5 print("My " + animal_type + "'s 阅读全文
posted @ 2019-02-24 02:12 波波皮球 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 1 prompt = "\nPlease tell me your age." 2 prompt += "\nEnter 'quit' to end." 3 message = '' 4 switch = True 5 while switch: 6 7 message = input(prompt 阅读全文
posted @ 2019-02-23 23:26 波波皮球 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 1 # greeter 7.11 2 3 # promt = "If you tell us who you are, we can personalize messages you see." 4 # promt += "\nWhat is your first name?" 5 # 6 # na 阅读全文
posted @ 2019-02-21 18:12 波波皮球 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1 python_vocabulary = {'import this': 'Zen of python', 2 'insert': '插入', 3 'range': '范围', 4 'popped': '术语弹出' 5 } 6 print(python_vocabulary) 7 8 for vo 阅读全文
posted @ 2019-02-21 12:20 波波皮球 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 1 python_vocabulary = {'import this': 'Zen of python', 2 'insert': '插入', 3 'range': '范围', 4 'popped': '术语弹出' 5 } 6 print(python_vocabulary) 7 8 for vo 阅读全文
posted @ 2019-02-21 12:19 波波皮球 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 1 #第五章if语句 2 #每条if 语句的核心都是一个值为True 或False 的表达式,这种表达式被称为条件测试 3 cars = ['audi', 'bmw', 'subaru', 'toyota'] 4 for car in cars: 5 if car == 'bmw': #粗心 两个等 阅读全文
posted @ 2019-02-19 01:22 波波皮球 阅读(141) 评论(0) 推荐(0) 编辑