gpt4 book ai didi

react-graph-vis - 如何读取 txt 并将其数据存储在列表中?

转载 作者:行者123 更新时间:2023-12-04 12:31:52 26 4
gpt4 key购买 nike

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


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

我只是尝试将变量设置为 redfile

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

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

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

最佳答案

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

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


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


newList = []

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

关于react-graph-vis - 如何读取 txt 并将其数据存储在列表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68520099/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com