-1
我調試名爲test.py因爲這python程序:如何在python中輸入字符串作爲argv?
#!/bin/env python
import sys
print sys.argv[1]
當我輸入這個命令,結果是迷惑:
[[email protected] ~]# python test.py "{"execute": "guest-execute", "session": "4768", "arguments": {"commands": [{"command": "/bin/sh", "arguments": ["sh", "-c", "ping -c 1 8.8.8.8"]}]}}"
結果是:
{execute: guest-execute, session: 4768, arguments: {commands: [{command: /bin/sh, arguments: [sh, -c, ping
我期望的應該是:
{"execute": "guest-execute", "session": "4768", "arguments": {"commands": [{"command": "/bin/sh", "arguments": ["sh", "-c", "ping -c 1 8.8.8.8"]}]}}
如何解決這個問題?我的程序中是否有錯或者程序中有什麼問題?謝謝〜