Python与其他语言一样拥有自己打开文件的函数。
“open”
我们可以使用open函数打开一个文件,并用read读取。
with open('read.txt',encoding='utf-8') as f:
for line in f:
print(line)
open后可跟很多参数,'read.txt‘是文件的绝对路径
Python与其他语言一样拥有自己打开文件的函数。
“open”
我们可以使用open函数打开一个文件,并用read读取。
with open('read.txt',encoding='utf-8') as f:
for line in f:
print(line)
open后可跟很多参数,'read.txt‘是文件的绝对路径