Discuss / Python / python文件指针移动后获取文件内容问题

python文件指针移动后获取文件内容问题

黄景杨yang

#1 Created at ... [Delete] [Delete and Lock User]

main = input('请输入查找内容:') with open('配置文件.txt','r+',encoding='utf-8') as f: text = f.read() f.seek(text.find(main)) print(f.tell()) print(f.read()) 在读取完文件之后,我把指针移动会自己输入要搜索的位置,再读取时,读取到的内容位置不对。请问这是为什么??


  • 1

Reply