Python 文件 IO

Python 3 教程 · 2019-02-12 14:43:36

以下代码演示了Python基本的文件操作,包括 open,read,write:

实例(Python 3.0+)

# Filename : test.py # author by : www.codercto.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)

执行以上代码输出结果为:

该文本会写入到文件中
看到我了吧!

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

零基础学算法

零基础学算法

戴艳 / 机械工业出版社 / 2012-3-1 / 69.00元

零基础学算法(第2版),ISBN:9787111372493,作者:戴艳 等编著一起来看看 《零基础学算法》 这本书的介绍吧!

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具