我正在尝试从Windows迁移到Linux,我的一些Python代码在迁移过程中没有幸存下来。你知道吗
这是Windows版本:
path = r'C:\\Users\\x\\PythonTestFiles\\TestFile.csv'
file = open(path, newline='')
TestFileRaw = csv.reader(file)
header = next(TestFileRaw)
dataPC = [row for row in TestFileRaw]
等等。。。。你知道吗
我试图在某个目录中对csv文件进行寻址,但我搞不清Linux的寻址方式。你知道吗
有人能帮忙吗?你知道吗
下面是一些关于linux directory structure的信息
在文件上按Alt+Enter,然后在“属性”对话框中将路径复制到其根目录,例如
/home/<user_name>/Documents
,然后用csv文件的file name
附加该路径。你知道吗最后,csv文件的路径变成
/home/<user_name>/Documents/filename.csv
在linux中使用csv文件的任何路径!你知道吗
您可以使用来自
os
模块的分隔符:这样它就可以独立于Windows/Linux。你知道吗
这是official documentation to os.path module。你知道吗
相关问题 更多 >
编程相关推荐