seminar:python実用スクリプト
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| seminar:python実用スクリプト [2020/08/20 17:17] – [Python実用スクリプト] kimi | seminar:python実用スクリプト [2020/08/20 17:30] (現在) – 削除 kimi | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ====== Python実用スクリプト ====== | ||
| - | * [[python_tutorial|即席ヘビ使い講座]] | ||
| - | |||
| - | * ファイル名は'' | ||
| - | |||
| - | * ターミナルで< | ||
| - | $ python ○○○○.py | ||
| - | </ | ||
| - | |||
| - | * VTKやRasMol, | ||
| - | $ python -i ○○○○.py | ||
| - | </ | ||
| - | |||
| - | ---- | ||
| - | |||
| - | 詳細は[[python_tutorial|即席ヘビ使い講座]]もしくは別稿「[[http:// | ||
| - | |||
| - | ===== Pythonで「コマンド」をつくるときの雛形 ===== | ||
| - | <code python> | ||
| - | # | ||
| - | from optparse import OptionParser | ||
| - | |||
| - | cmd = OptionParser(usage = '%prog [-t] [-p X Y Z] input_file output_file' | ||
| - | |||
| - | cmd.add_option(' | ||
| - | help = ' | ||
| - | |||
| - | cmd.add_option(' | ||
| - | help = ' | ||
| - | | ||
| - | |||
| - | (opt, argv) = cmd.parse_args() | ||
| - | |||
| - | if len(argv) != 2: | ||
| - | cmd.print_help() | ||
| - | raise SystemExit | ||
| - | |||
| - | input_file = argv[0] | ||
| - | output_file = argv[1] | ||
| - | option_on_off = opt.toggle | ||
| - | option_xyz = opt.position | ||
| - | |||
| - | </ | ||
seminar/python実用スクリプト.1597911420.txt.gz · 最終更新: (外部編集)