以t模式为基础进行内存操作
r(默认的操作模式):只读模式,当文件不存在时报错,当文件存在时文件指针跳到最开始位置
with open ('ccc.txt',mode='rt',encoding='utf-8') as f:
print('第一次读'.center(50,'*'))
res = f.read() #把所有内容从硬盘读入内存
print(res)
with open ('ccc.txt',mode='rt',encoding='utf-8') as f:
print('第二次读'.center(50,'*'))
res1 = f.read() #把所有内容从硬盘读入内存
print(res1)
r模式小案例:
inp_username = input('your name:').strip
inp_password = input('your pwd:').strip
with open('user.txt',