python:examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
python:examples [2016/08/03 08:14] – [Get Parameters from main] admin | python:examples [2016/08/03 08:53] (current) – removed admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Python Examples ====== | + | |
- | ===== Get Parameters from main ===== | + | |
- | * Create simple code mainparams.py:< | + | |
- | import sys | + | |
- | nargs = len(sys.argv) | + | |
- | outpath = '' | + | |
- | paramename = ' | + | |
- | print sys.argv | + | |
- | if nargs > 1: | + | |
- | paramename = sys.argv[1] | + | |
- | print ' | + | |
- | </ | + | |
- | * run:< | + | |
- | mainparams.py hello | + | |
- | </ | + | |
- | [' | + | |
- | paramename = hello | + | |
- | </ | + | |
- | ===== Python Json ===== | + | |
- | * Simple example for parsing Json:< | + | |
- | import json | + | |
- | json_string = ' | + | |
- | parsed_json = json.loads(json_string) | + | |
- | print parsed_json | + | |
- | </ | + | |
- | {u' | + | |
- | </ | + | |
- | {u' | + |
python/examples.1470212076.txt.gz · Last modified: 2022/10/29 16:15 (external edit)