我想通过命令行上的json将一组简单的名称/值对传递给python脚本。在
$ curl -s https://jsonplaceholder.typicode.com/posts/1 | python3.6 -c 'import sys, json; print json.load(sys.stdin)'
File "<string>", line 1
import sys, json; print json.load(sys.stdin)
^
SyntaxError: invalid syntax
(23) Failed writing body
json很简单:
^{pr2}$目标是分配变量,如:
if json.load(sys.stdin)["title"] is not None:
post_title = json.load(sys.stdin)["title"]
我怎样才能正确地完成这个任务?在
在
print
的参数周围需要括号:相关问题 更多 >
编程相关推荐