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

查看所有标签

BSD Hacks

BSD Hacks

Dru Lavigne / O'Reilly Media, Inc. / 2004-05-24 / USD 24.95

If you want more than your average BSD user--you want to explore and experiment, unearth shortcuts, create useful tools, and come up with fun things to try on your own--BSD Hacks is a must-have. This ......一起来看看 《BSD Hacks》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

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

HEX CMYK 互转工具