繁体   English   中英

如何用Python打开文件名中的空格?

[英]How to open a file with Python with white spaces in the name?

我有没有空格就不能重命名的文件(工作文件)。 文件名是Evo PROG6001 FSJD0250240 E.PART存储在变量file 如果我运行os.system('start ' "'" + file + "'")它只能识别单词Evo并返回Windows cannot find "Evo". Make sure you types the name correctly, and then try again Windows cannot find "Evo". Make sure you types the name correctly, and then try again os.system('start ' + file)也会发生同样的事情。

有没有办法做到这一点?

我需要使用os.startfile()并将其指向我之前存储的根目录。

os.startfile(new_folder + '\\\\' + file)有效

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM