标签:name with open append div print == while NPU content
import os def get_fname(): while True: f_name = input(‘输入用户名:‘) if not os.path.exists(f_name): break print(‘%s已存在,青重新输入‘%f_name) return f_name def get_content(): content = [] while True: data = input(‘input> ‘) if data == ‘quit‘: break content.append(data) return content def write_file(f_name, f_content): with open(f_name, ‘w‘) as f: for line in f_content: f.write(line+‘\n‘) def main(): f_name = get_fname() f_content = get_content() write_file(f_name, f_content) if __name__ == "__main__": main()
标签:name with open append div print == while NPU content
原文地址:https://www.cnblogs.com/ray-mmss/p/10529381.html