Python 按行读取文件

2022-02-22  本文已影响0人  GloryMan

import re

def read_file_text():
s = []
f = open('yingyu.txt', 'r')
for lines in f:
ls = lines.strip(' ').replace(' ', '').replace('\n', '').replace('?', '').split('/')
for inx,val in enumerate(ls):
s.append(val)
print(s)
f.close()

Press the green button in the gutter to run the script.

if name == 'main':
read_file_text()

上一篇下一篇

猜你喜欢

热点阅读