开发者社区> 问答> 正文

Python 文件 IO

Python 文件 IO

展开
收起
游客ejnn55cgkof5g 2020-02-14 17:38:07 890 0
1 条回答
写回答
取消 提交回答
  • # Filename : test.py
    # author by : www.runoob.com
     
    # 写文件
    with open("test.txt", "wt") as out_file:
        out_file.write("该文本会写入到文件中\n看到我了吧!")
     
    # Read a file
    with open("test.txt", "rt") as in_file:
        text = in_file.read()
     
    print(text)
    执行以上代码输出结果为:
    
    该文本会写入到文件中
    看到我了吧!
    2020-02-14 17:38:28
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载