读取文件
读取文件详细操作教程
以下实例为学习读取文件,具体代码如下:
# Filename : example.py
# Author by : www.lidihuo.com
f = open("demofile.txt", "r")
print(f.read())
执行以上代码输出结果为:
# Filename : example.py
# Author by : www.lidihuo.com
Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!