我正在尝试写入一个名为
data/STO: INVE-B-TIME_SERIES_DAILY_ADJUSTED-1.csv
在 Windows 上使用以下 python 代码
overwrite = "w" # or write new
f = open(OutputPath(copyNr), overwrite)
f.write(response.content.decode('utf-8'))
f.close()
print(f"Wrote to file: {OutputPath(copyNr)}")
控制台中的输出是正确的,但写入的文件仅导致data/STO路径似乎被剪切。我尝试使用此答案中的方法转义字符,但这给了我以下文件名的 invalid_argument 异常:
data/STO\\:\\ INVE-B-TIME_SERIES_DAILY_ADJUSTED-1.csv
当我删除空格时,我遇到了同样的错误,但它似乎仍然在 处剪辑:。如何在文件名中包含此类字符?
智慧大石
婷婷同学_
相关分类