标签:username json put col error: ack com data- bsp
import json def get_stored_username(): """如果获取了用户名,就获取她""" filename = ‘username.json‘ try: with open(filename) as file_obj: username = json.load(file_obj) except FileNotFoundError: return None else: return username def get_new_username(): """提示用户输入用户名""" filename = ‘username.json‘ username = input("Please input your name\n") with open(filename,‘w‘) as file_obj: json.dump(username,file_obj) """写入数据,从左写入右""" return username def greet_user(): """问候用户""" username = get_stored_username() if username: print(username + " Welcome back\n") else: username = get_new_username() greet_user()
标签:username json put col error: ack com data- bsp
原文地址:http://www.cnblogs.com/kunpengv5/p/7591095.html