2023年2月6日
摘要: anonymousSurvey.py class AnonymousSurvey(): """收集匿名调查问卷的答案""" def __init__(self, question): """存储一个问题,并为存储答案做准备""" self.question = question self.respo 阅读全文
posted @ 2023-02-06 17:09 Zoie_ting 阅读(26) 评论(0) 推荐(0) 编辑
摘要: import json print(" 读取文件 ") # 关键字with 在不再需要访问文件后将其关闭,让Python负责妥善地打开和关闭文件 with open('pi_digits.txt') as file_object: contents = file_object.read() prin 阅读全文
posted @ 2023-02-06 17:06 Zoie_ting 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 类名应采用驼峰命名法,即将类名中的每个单词的首字母都大写,而不使用下划线。实例名和模块名都采用小写格式,并在单词之间加上下划线。 对于每个类,都应紧跟在类定义后面包含一个文档字符串。这种文档字符串简要地描述类的功能,并遵循编写函数的文档字符串时采用的格式约定。每个模块也都应包含一个文档字符串,对其中 阅读全文
posted @ 2023-02-06 11:34 Zoie_ting 阅读(12) 评论(0) 推荐(0) 编辑
摘要: pizza.py def make_pizzas(size, *toppings): """概述要制作的比萨""" print('size:' + size) print(toppings) def test_one(): print('one') def test_two(): print('tw 阅读全文
posted @ 2023-02-06 11:32 Zoie_ting 阅读(17) 评论(0) 推荐(0) 编辑
摘要: # 函数input() 让程序暂停运行,等待用户输入一些文本。 # 获取用户输入后,Python将其存储在一个变量中,以方便你使用 message = input("Tell me something, and I will repeat it back to you: ") print(messa 阅读全文
posted @ 2023-02-06 11:31 Zoie_ting 阅读(33) 评论(0) 推荐(0) 编辑
摘要: alien_0 = {'color': 'green', 'points': 5} print(alien_0['color']) print(alien_0['points']) print(alien_0) alien_0['x_position'] = 0 alien_0['y_positio 阅读全文
posted @ 2023-02-06 11:31 Zoie_ting 阅读(18) 评论(0) 推荐(0) 编辑
摘要: cars = ['audi', 'bmw', 'aubaru', 'toyota'] for car in cars: if car == 'bmw': print(car.upper()) else: print(car.title()) # and or age = 18 age_0 = 20 阅读全文
posted @ 2023-02-06 11:30 Zoie_ting 阅读(24) 评论(0) 推荐(0) 编辑
摘要: bicycles = ["trek", "cannondale", "redline"] print(bicycles[0]) print(bicycles[0].title()) # 索引为-1,返回最后一个元素 print(bicycles[-1]) print(bicycles[-1].tit 阅读全文
posted @ 2023-02-06 11:30 Zoie_ting 阅读(12) 评论(0) 推荐(0) 编辑
摘要: message = "hello world" print(message) message = "Let's go" print(message) # title()以首字母大写显示每个单词 name = "zhou yu ting" print(name.title()) name = "ZHO 阅读全文
posted @ 2023-02-06 11:29 Zoie_ting 阅读(12) 评论(0) 推荐(0) 编辑