ITPub博客

首页 > IT职业 > IT图书 > Python的学习

Python的学习

IT图书 作者:peace72 时间: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/4577/viewspace-2802737/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: python笔记-set
请登录后发表评论 登录
全部评论

注册时间:2019-08-13

  • 博文量
    0
  • 访问量
    479