What does "-c" mean in this linux shell command?

Viewed 1282

It's from a tutorial on the google cloud platform, they call python from the Linux Shell. I'm totally new to gcp and linux, please help me, where can I find some exhaustive documentation for python tools in Linux?

python -c 'import base64, sys, json; \
  img = base64.b64encode(open(sys.argv[1], "rb").read()); \
  print json.dumps({"key":"1", "image_bytes": {"b64": img}})' \
  flower1.jpg > request.json
3 Answers

When called with -c command, it executes the Python statement(s) given as command. Here command may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements!

-c stand for cmd which allows you to pass your code as a string. This feature is available even outside of google-cloud-platform. you can check other available options using python -h

Related