从列表中阅读

reading behind from list

import numpy as np

filename = 'input1.txt'
output_file = 'output.txt'
delimiters = ',.?!'

with open(filename, 'r') as f:
    text = f.read()
for delimiter in delimiters:
    text = text.replace(delimiter, ',')
lines = text.split('\n')
parts = list()
print(lines)

我希望后面所有包含文本/数字的行都在 sheet

示例我有一个 input.text 文件

1,2,3,4,5,6
7,8,9,10,11,12
13,14,15,16,17

这个给我

['1,2,3,4,5,6', '7,8,9,10,11,12', '13, 14,15,16,17 ',' ',' ',' ', '', '', '', '', '']

我在找后面的出口看台词

['13, 14,15,16,17', '7,8,9,10,11,12', '1,2,3,4,5,6', '', '', '', '', '', '', '']

感谢您的帮助

反转 Python 中的列表:

print(list('abc')[::-1])
> ['c', 'b', 'a']

您的情况:

import numpy as np
import re
filename = 'input1.txt'
output_file = 'output.txt'
text = re.sub('[.?!]', ',', text)

with open(filename, 'r') as f:
    text = f.read()
text = re.sub('[.?!]', ',', text)

lines = text.split('\n')[::-1]
parts = []
print(lines)