标签:__name__ 练手 ase int def port 入口 print pre
# hello3.py
import 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()
标签:__name__ 练手 ase int def port 入口 print pre
原文地址:https://www.cnblogs.com/lhm-test/p/12693265.html