pythonでjsonを整形 スクリプト #!/usr/bin/env python # encoding: utf-8 import json dict = json.loads(raw_input()) format_json = json.du… Okuyaハック2016.03.11 2,128
boto3を使う時のファイル名 boto.py #!/usr/bin/env python # -*- coding:utf-8 -*- import boto conn = boto.connect_s3() を実行したら、 $ ./boto.py … Okuyaハック2016.03.09 687
シグナルを使ったときにハマったこと こんなスクリプトを import signal, os import time def handler(signum, frame): print signum print “i am heavy…” # なにか重い… 駆け出し 太郎ハック2016.03.08 1,280
python2の記法のメモ ifの条件式で… 以下のような書き方が許されている。 if 1 < x < 10: … 文字列 strip() >>> a = ‘abcd1234’ >>>… Okuyaハック2016.03.04 577
【Python】オブジェクトが特定の特定の属性を持っているか has_attr = hasattr(instance, “attr_name”) # 使用例としては、こうなるのかと存じます if hasattr(instance, “attr”) and instance.attr… 駆け出し 太郎ハック2016.03.04 361
pythonでAWSのSNSを使う pythonでAWSのSNSを使いたいとき まず、AWS SDK for Python (Boto3)をインストール。 pip install boto3 そして、下のスクリプトを実行すればメール送信完了。(適宜、変更し… Okuyaハック2016.03.04 1,018
gspread sheetにpython APIでログイン ログイン(oauth2を使わない場合) import gspread # Login with your Google account gc = gspread.login(‘thedude@abid.es’,’****… Okuyaハック2016.03.02 502
【Python】いい感じに例外をログへ吐く コード import sys import traceback try: 0/0 except: # print traceback.print_exc() # as string exc_type, exc_value… 駆け出し 太郎ハック2016.03.01 1,656
google spread sheetをPythonでいじりたい インストール pip install gspread pip install –upgrade google-api-python-client 以下実行 # -*- coding:utf-8 -*- import j… Okuyaハック2016.03.01 1,229