マニュアル ・ 教材関係

.vimrc 設定 (python ファイルに対してだけ有効)

autocmd FileType python setl autoindent
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl tabstop=8 expandtab shiftwidth=4 softtabstop=4

ファイル読み込み(コマンドライン引数でファイル名を指定、エラー処理付き)

import sys
script_name = sys.argv[0]
try:
    file_name = sys.argv[1]
    file_desc = open(file_name, 'r')
except IndexError:
    print 'Usage: %s TEXTFILE' % script_name
except IOError:
    print '"%s" cannot be opened.' % file_name
else:

    # ファイルを一行ずつ読み込む場合
    for line in file_desc:
        print line

    # ファイル全体をまとめてリストに読み込む場合
    lines = file_desc.readlines()
    print lines    

    file_desc.close()

数字の整形(桁区切り、小数点の丸め)

>>> "{:,}".format(1234.5678)
'1,234.5678'

>>> "{:,.2f}".format(1234.5678)
'1,234.57'

logging.debug("size  = %s byte", "{:,}".format(vfp_size))

print の自動改行を無効化

文字列を指定したセパレータで分解する

python で正規表現を使う方法

import re
group()マッチした文字列を返す
start()マッチした文字列の開始位置を返す
end()マッチした文字列の終了位置を返す
span()マッチした文字列の (開始位置, 終了位置) のタプルを返す

Python 日付、時刻の処理 (外部モジュール dateutil)

SQLite

Open CV

Django

[local] munakata:~/source/python/vlman/vlmanui$ python3 manage.py makemigrations
Migrations for 'fview':
  fview/migrations/0001_initial.py
    - Create model Filedir

[local] munakata:~/source/python/vlman/vlmanui$ python3 manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, fview, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying fview.0001_initial... OK
  Applying sessions.0001_initial... OK

pylint 関連

PyAV

python-pptx

Progate

paiza

参考 URL


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS