Python用vimrc
syntax enable set number set ts=4 set autoindent set expandtab set shiftwidth=4 set cursorline set showmatch let python_highlight_all = 1
PythonでJSON読み込み
import urllib2 import json req = urllib2.Request('geturl') response = urllib2.urlopen(req) r = response.read() decode_json_data = json.loads(r) getmail_list = decode_json_data['emails']
ディレクトリ下をgrep
find / -type f -print | xargs grep "hogehoge"
Pythonで実行時間を測る
import time start = time.time() #Do Something elapsed_time = time.time() - start print ("Elapsed:{0}".format(elapsed_time) + "[Sec]")
Pythonでリストを一意のリストへ
TargetList = list(set(TargetList))
User-Agentを指定してURLの内容を取得
2系で確認
import urllib2 geturl = 'http://www.google.com' req = urllib2.Request(geturl, headers={'User-Agent' : "Some Browser"}) response = urllib2.urlopen(req) html = response.read()
GAEで既にデプロイ済みのアプリのソースをダウンロード(Python)
基本的な書式
# appcfg.py download_app -A <your_app_id> -V <your_app_version> <output-dir>
認証に失敗する場合は--oauth2をつけて実行
appcfg.py download_app -A appname -V 1 /downloaddir --oauth2