cmd = ['python','test.py','--input=你好']
cmd = [c.encode('utf-8').hex() for i in cmd]
subprocess.Popen(cmd, env=current_env)
in test.py
input = bytes.fromhex(args.input).decode('utf-8')
本文探讨了在Python的subprocess模块使用Popen函数时遇到包含中文字符的命令如何正确处理,确保命令能够被执行。通过示例代码和解决方法,帮助读者解决这一常见问题。
cmd = ['python','test.py','--input=你好']
cmd = [c.encode('utf-8').hex() for i in cmd]
subprocess.Popen(cmd, env=current_env)
in test.py
input = bytes.fromhex(args.input).decode('utf-8')
1462
7120

被折叠的 条评论
为什么被折叠?