脚本 01.py:
import sys
import json
k = sys.argv[1]
print(k)
print(type(k))
print(json.loads(k))
终端命令行启动,注意用双引号包裹:
python 01.py "{\"name\": \"girl\", \"age\": 16}"
调用结果:
{"name": "girl", "age": 16}
<class 'str'>
{'name': 'girl', 'age': 16}
脚本 01.py:
import sys
import json
k = sys.argv[1]
print(k)
print(type(k))
print(json.loads(k))
终端命令行启动,注意用双引号包裹:
python 01.py "{\"name\": \"girl\", \"age\": 16}"
调用结果:
{"name": "girl", "age": 16}
<class 'str'>
{'name': 'girl', 'age': 16}