怎么用python读取txt文件里指定行的内容,并导入

2024-01-14 08:21:07
推荐回答(2个)
回答1:

path01=“d://folder1//folder2//text01.txt”
oprtype01='r'#oprtype01标识打开类型:'r'为只读
nline01=10#读取行数
file01=open(path01,oprtype01)
lines01=file01.readline(nline01)

回答2:

nline01 = 10 只是将utf-8的编码前10个字符标识出来进行读取,无法读取固定哪一行