在调用os.system执行命令时,发现system不能接受unicode的命令。那么命令中却又包含以unicode表示的中文等字符怎么办?

——方法就是将unicode转化为utf8

path = u'我的文件.txt'
cmd = 'process'
cmd += ' '+ path.encode('utf8')
os.system(cmd)

 

相关文章:

  • 2021-06-16
  • 2021-08-19
  • 2021-05-20
  • 2021-11-05
  • 2021-03-31
  • 2021-07-08
  • 2022-02-07
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2021-08-22
  • 2021-09-21
  • 2022-03-05
  • 2021-07-03
相关资源
相似解决方案