python读取文件每行_python-读取txt文件每行数据的第一个

时间: 2023-07-29 admin 互联网

python读取文件每行_python-读取txt文件每行数据的第一个

python读取文件每行_python-读取txt文件每行数据的第一个

原博文

2020-02-11 19:50 −

利用split进行分割

f=open("output.txt","r", encoding = 'utf-8',errors='ignore')

for line in f: print(line.split(' ')[0])

原文件:

效果:

...

相关推荐

2019-09-11 18:11 −

1 from xlwt import * 2 import os 3 #------------------读数据--------------------------------- 4 #判断是否存在有此类型的文件且文件名一致 5 #---mrs_vgw--- 6 fileName_mr...

2019-11-22 17:44 −

全代码:

import requests

from bs4 import BeautifulSoup

import os

import time

import sys

import io

sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='...

1

217

2019-12-06 19:14 −

#