gpt4 book ai didi

python - IPython 从 Ubuntu 到 Windows UNC 路径

转载 作者:太空宇宙 更新时间:2023-11-04 03:34:03 26 4
gpt4 key购买 nike

我在 Windows 10 上通过 Anaconda 使用 IPython 3.4(是的,我知道)。我在虚拟机上的 Ubuntu 中使用相同版本的 IPython 编写了一个脚本,并尝试在 Windows 端运行它。我一直在尝试解决 Linux 中使用“/”作为文件路径(而不是 Windows 中使用“\”)的问题。我尝试简单地将 Windows 端的所有“/”实例转换为“\”,但仍然收到以下错误:

OSError: [Errno 22] Invalid argument:
C:\\Users\\mike\\Desktop\\S15 NWEA\\Combined_CSVs\\Students_All 2015-08-27 20:12:34.csv'

我希望有一个简单的解决方案。有吗?

这是整个错误输出:

OSError Traceback (most recent call last)
<ipython-input-5-b1a80a7377c7> in <module>()
37 Sframe = pd.concat(list,ignore_index=False)
38
---> 39 Sframe.to_csv(str(out_folder)+'\Combined_CSVs\Students_All '+str(st)+'.csv', sep=',')
40 ##Concatenate fields and check for duplicates
41 Sframe["TermSchoolStudent"]=Sframe["TermName"]+Sframe["SchoolName"]+Sframe["StudentID"].map(str)

C:\Users\mike\Anaconda3\lib\site-packages\pandas\core\frame.py in to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, quoting, quotechar, line_terminator, chunksize, tupleize_cols, date_format, doublequote, escapechar, decimal, **kwds)
1187 escapechar=escapechar,
1188 decimal=decimal)
-> 1189 formatter.save()
1190
1191 if path_or_buf is None:

C:\Users\mike\Anaconda3\lib\site-packages\pandas\core\format.py in save(self)
1440 else:
1441 f = com._get_handle(self.path_or_buf, self.mode,
-> 1442 encoding=self.encoding)
1443 close = True
1444

C:\Users\mike\Anaconda3\lib\site-packages\pandas\core\common.py in _get_handle(path, mode, encoding, compression)
2827 f = open(path, mode, encoding=encoding)
2828 else:
-> 2829 f = open(path, mode, errors='replace')
2830 else:
2831 f = open(path, mode)

OSError: [Errno 22] Invalid argument:
C:\\Users\\mike\\Desktop\\S15 NWEA\\Combined_CSVs\\Students_All 2015-08-27 20:12:34.csv'

提前致谢,迈克尔

最佳答案

问题出在输出 CSV 中名为 2015-08-27 20:12:34.csv 的部分。在 Linux 中,我可以在文件名中使用破折号和冒号,但在 Windows 中却不行。

关于python - IPython 从 Ubuntu 到 Windows UNC 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32261536/

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