02 2019 档案

摘要:# 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 波波皮球 阅读(97) 评论(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 波波皮球 阅读(135) 评论(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 波波皮球 阅读(83) 评论(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 波波皮球 阅读(202) 评论(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 波波皮球 阅读(105) 评论(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 波波皮球 阅读(68) 评论(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 波波皮球 阅读(114) 评论(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 波波皮球 阅读(152) 评论(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 波波皮球 阅读(144) 评论(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 波波皮球 阅读(173) 评论(0) 推荐(0)
摘要:1 1 # 3.3.1 使用方法sort() 对列表进行永久性排序 2 2 # 与字母顺序相反的顺序排列列表元素,为此,只需向sort() 方法传递参数reverse=True 。下面的示例将汽车列表按与字母顺序相反的顺序排列: 3 3 cars = ['bmw', 'audi', 'toyota' 阅读全文
posted @ 2019-02-18 00:02 波波皮球 阅读(192) 评论(0) 推荐(0)
摘要:1 bicycles = ['trek','connondale','redline','specialized'] 2 print(bicycles[0]) 3 4 bicycles = ['trek','connondale','redline','specialized'] 5 print(bicycles[0].title())#首字母大写 6 7 #... 阅读全文
posted @ 2019-02-16 21:04 波波皮球 阅读(205) 评论(0) 推荐(0)
摘要:#day11#expandtabs 断句20 如果占用20个字就不用填充 反之可用/t来填充test = "username\temail\tpassword\nlaiying\tlaiasd@qq.com\t123\nlaiying\tlaiasd@qq.com\t123\nlaiying\tla 阅读全文
posted @ 2019-02-15 00:30 波波皮球 阅读(89) 评论(0) 推荐(0)
摘要:1 #用户登录(三次机会重试) 2 #老师答案(最后两行自添) 3 count = 0 4 while count >>') 6 pwd = input('>>>') 7 if user == 'alex' and pwd == '123': 8 print('欢迎登录') 9 print('..........') 10 ... 阅读全文
posted @ 2019-02-13 20:45 波波皮球 阅读(87) 评论(0) 推荐(0)
摘要:while count <= 10 : if n == 7 : #冒号不要忘记 1 #1.输出100以内的所有偶数 2 """ 3 #自己代码 4 count = 0 5 while count < 101: 6 7 count = count + 1 8 if count % 2 == 0: 9 阅读全文
posted @ 2019-02-12 22:34 波波皮球 阅读(90) 评论(0) 推荐(0)