我试图在chromebook上读取一个.txt文件来操作那里的数据。我的文件源代码是:
def readInFile():
arr_intValues = []
myFile = open("#MY FILE HERE", "r")
#you need to change the directory
for myLine in myFile:
arr_intValues.append(int(myLine))
return arr_intValues
myNewList = readInFile()
print(myNewList)问题是,我找不出该代码的文件源在哪里。如果我将文件放到一个铬选项卡中,它会读到:
file:///media/fuse/crostini_9549350604ce9beeb7d5a9a66d5bf09733144d34_termina_penguin/RandomNum.txt
同时,“获取信息”返回的文件位置是:
我的文件/Linux文件/RandomNum.txt
如果我试图打开它并在我的代码中打印它,这两个选项都失败了。
如何找到正确的文件目录?
我试图在使用Chrome时找到一个.txt文件的目录,但没有成功。
发布于 2022-12-03 02:14:37
如果在Linux上运行程序,则需要指定Linux路径。

https://stackoverflow.com/questions/74663389
复制相似问题