class bank:
def user\_info(self):
a=input('请输入用户信息:')
# 不写encoding = 'utf-8'中文会乱码
with open('info.txt','w',encoding='utf-8') as f:
f.write(a)
def get\_info(self):
with open('info.txt','r',encoding='utf-8') as f:
print(f.read())
bank().get_info()
代码运行结果:
D:\py学习01\venv\Scripts\python.exe D:/py学习01/python基础/EX03.py
wiiofff非后方可
手机扫一扫
移动阅读更方便
你可能感兴趣的文章