内容へ移動
メモとかメモのようなものとか(By ルーキーの中のひと)
ユーザ用ツール
ログイン
サイト用ツール
検索
ツール
文書の表示
以前のリビジョン
ODT 出力
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
最近の変更
メディアマネージャー
サイトマップ
トレース:
development:language:python
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== Python ====== ===== 各種ツールの変遷など ===== [[https://www.m3tech.blog/entry/python-packaging|Pythonのパッケージ周りのベストプラクティスを理解する]] ===== argparse ===== コマンドラインオプション、引数、サブコマンドのパーサー <code python> import argparse parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('integers', metavar='N', type=int, nargs='+', help='an integer for the accumulator') parser.add_argument('--sum', dest='accumulate', action='store_const', const=sum, default=max, help='sum the integers (default: find the max)') args = parser.parse_args() print args.accumulate(args.integers) </code> ==== 参考 ==== http://docs.python.jp/2/library/argparse.html http://ja.pymotw.com/2/argparse/ ===== chown ===== <code python> import os os.chown(target, uid, gid) </code> chown -R のように再帰的に変更する場合 <code python> for root, dirs, files in os.walk(target_dir): for dir in dirs: os.chown(os.path.join(root, dir), 888, 50) for file in files: os.chown(os.path.join(root, file), 888, 50) </code> ===== エラー ===== 以下のようなエラー bash: ./pytest.py: /usr/local/bin/python2.7^M: bad interpreter: No such file or directory windowsで作成したソースをアップロードして実行したときにたまに発生する。\\ 改行コードを「**LF**」にしてやると治った。
development/language/python.txt
· 最終更新: 2019/07/02 12:04 by
hayashi
ページ用ツール
文書の表示
以前のリビジョン
バックリンク
ODT 出力
文書の先頭へ