ITPub博客

首页 > IT职业 > IT职场 > Python输出文件的内容

Python输出文件的内容

IT职场 作者:tomlzy 时间:2021-09-09 09:22:11 0 删除 编辑

import os
document = open("testfile.txt", "w+")
print("文件名: ", document.name);
document.write("这是我创建的第一个测试文件!nwelcome!")# n表示换行
print(document.tell())#估计是读取有多少个字节
document.seek(os.SEEK_SET)#没有这一句,读不出文件的内容
context = document.read()
print(context)
document.close();

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3278/viewspace-2802738/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: JS异步编程 (1)
请登录后发表评论 登录
全部评论

注册时间:2019-08-13

  • 博文量
    83
  • 访问量
    653