python subprocess and unicode execv() arg 2 must contain only strings

前端 未结 1 1654
走了就别回头了
走了就别回头了 2021-01-11 13:39

I have a django site where I need to call a script using subprocess. The subprocess call works when I\'m using ascii characters but when I try to issue arguments that are ut

相关标签:
1条回答
  • 2021-01-11 14:15

    You should encode the Unicode strings in the encoding your program expects. If you know the program expects UTF-8:

    u'Wiadomo\u015b\u0107'.encode('utf8')
    

    If you don't know what encoding you need, you could try your platform's default encoding:

    u'Wiadomo\u015b\u0107'.encode()
    
    0 讨论(0)
提交回复
热议问题