Jan 10, 2013

Python shell command

Execute code:
python -c "print 'hi.'"
# or
echo "print 'hi.'" | python '-'
# equal to
echo "print 'hi.'" | python -- -
Execute multiline code:
python '-' <<"EOF"
lines=2
print "\nThis script is %i lines long.\n" %(lines,)
EOF
Using json.tool to validate and pretty-print:
curl https://app01.nutshell.com/api/v1/json | python -m json.tool

No comments: