3
pathfile = "C:\Users\gk\Documents\toread"


readfile= open(pathfile+'.txt', 'r')

我试图将变量作为redfile

newList = []
newList = readfile
readfile.close()

所以然后发送一个获取该列表的图表。

但是当我生成图表时,我只是得到一个 None 。

4

1 回答 1

5

只需尝试使用 for 循环将 txt 的每一行保存在新列表中

pathfile = "C:\Users\gk\Documents\toread"


readfile= open(pathfile+'.txt', 'r')


newList = []

for i in readfile:
        newList.append(i)
readfile.close()

于 2021-07-25T15:43:38.143 回答