- ホーム /
- python
python2の記法のメモ
ifの条件式で… 以下のような書き方が許されている。 if 1 < x < 10: … 文字列 strip() >>> a = ‘abcd1234’ >>>… 【Python】オブジェクトが特定の特定の属性を持っているか
has_attr = hasattr(instance, “attr_name”) # 使用例としては、こうなるのかと存じます if hasattr(instance, “attr”) and instance.attr… pythonでAWSのSNSを使う
pythonでAWSのSNSを使いたいとき まず、AWS SDK for Python (Boto3)をインストール。 pip install boto3 そして、下のスクリプトを実行すればメール送信完了。(適宜、変更し… gspread sheetにpython APIでログイン
ログイン(oauth2を使わない場合) import gspread # Login with your Google account gc = gspread.login(‘thedude@abid.es’,’****… 【Python】いい感じに例外をログへ吐く
コード import sys import traceback try: 0/0 except: # print traceback.print_exc() # as string exc_type, exc_value… - 駆け出し 太郎
- ハック
- 2016.03.01
- 1,654
google spread sheetをPythonでいじりたい
インストール pip install gspread pip install –upgrade google-api-python-client 以下実行 # -*- coding:utf-8 -*- import j… 【Python】コード途中で改行
出来た。嬉しい。 if self.__baz is None \ or self.__foo is None \ or self.__bar is None: raise Exception(“exception”) 参… - 駆け出し 太郎
- ハック
- 2016.02.24
- 10,018
Pythonでunderscore.jsのpluck、groupByみたいなやつ
内包表記、おしゃれですね。 # underscore.jsのpluckみたいなやつ users = [{“userid”:1, “likes”:”cats”},{“userid”:2, “likes”:”cats”},{… - 駆け出し 太郎
- ハック
- 2016.02.24
- 1,045
Python始めた時にググったこと
from itertools import * # JavaScript で言う Array.prototype.find()的なやつだゾ predicate = lambda tag: tag[‘Key’] == ‘N…