代码之家  ›  专栏  ›  技术社区  ›  Chris Macaluso

如何用名称中包含空格的python打开文件?

  •  0
  • Chris Macaluso  · 技术社区  · 7 年前

    我有没有空白(工作文件)不能重命名的文件。文件名是 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 . 同样的事情发生在 os.system('start ' + file) .

    有办法吗?

    1 回复  |  直到 7 年前
        1
  •  2
  •   Chris Macaluso    7 年前

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

    os.startfile(new_folder + '\\' + file) 作品