subprocess.Popen with a unicode path

前端 未结 4 1643
面向向阳花
面向向阳花 2020-12-10 07:01

I have a unicode filename that I would like to open. The following code:

cmd = u\'cmd /c \"C:\\\\Pok\\xe9mon.mp3\"\'
cmd = cmd.encode(\'utf-8\')
subprocess.P         


        
4条回答
  •  囚心锁ツ
    2020-12-10 07:41

    >>> subprocess.call(['start', u'avión.mp3'.encode('latin1')], shell=True)
    0
    

    There's no need to call cmd if you use the shell parameter The correct way to launch an associated program is to use the cmd's start built-in AFAIK.

    My 2c, HIH.

提交回复
热议问题