
您需要使用以下命令将文件对象的索引重置为第一个位置
seek():
with open("outfile1.txt", 'r+') as f: f.write("foobar") f.flush() # "reset" fd to the beginning of the file f.seek(0) print("File contents:", f.read())这将使文件可供读取。
欢迎分享,转载请注明来源:内存溢出

您需要使用以下命令将文件对象的索引重置为第一个位置
seek():
with open("outfile1.txt", 'r+') as f: f.write("foobar") f.flush() # "reset" fd to the beginning of the file f.seek(0) print("File contents:", f.read())这将使文件可供读取。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)