# hello3.pyimport hello4 person = {‘Alice‘: 13, ‘Bob‘: 35, ‘May‘: 56, ‘Lin‘: 29}body_name = [‘head‘, ‘body‘, ‘hand‘, ‘leg‘, ‘foot‘] # 找出想要的字符串def number_name(): n = int(input(‘Input a number:\n‘)) if 0 < n < 5: print(body_name[n]) else: print("Please input a number in 0 and 4") hello4.get_time() # 找出年纪最大的人def age_old(): p_name = ‘Alice‘ for key in person.keys(): if person[p_name] < person[key]: p_name = key print(‘%s,%d‘, (p_name, person[p_name])) # 保存所有输入的字符串到test.txt文件中def save_text(): fp = open(‘text.txt‘, ‘w‘) string = input(‘Please input a string:\n‘) fp.write(string) fp.closed # __name__ == “__main__” 作为启动py文件的main函数入口if __name__ == "__main__": save_text()
原文地址:https://www.cnblogs.com/lhm-test/p/12693265.html
时间: 2024-10-11 21:02:15