mk-toolブログ

エンジニアと家のことをごちゃごちゃと書いてます

2018-01-01から1年間の記事一覧

【Python】TypeError: Unicode-objects must be encoded before hashing

概要 以下のエラーが出たためメモ。 TypeError: Unicode-objects must be encoded before hashing 解決策 文字列の末尾に.encode('utf-8')を追記する。

【Python】AttributeError: 'UUID' object has no attribute 'get_hex'

概要 以下のエラーが発生したためメモ。 AttributeError: 'UUID' object has no attribute 'get_hex' 解決法 get_hexをhexにする。 - key = self.prefix + uuid.uuid4().get_hex() + key = self.prefix + uuid.uuid4().hex

【Python】MySQLdb must be installed on the system

概要 以下のエラーが出たためメモ。 MySQLdb must be installed on the system 解決策 PyMySQLをinstallする。 pip3 install PyMySQL // もしくは pip install PyMySQL

【Python】throwされたErrorのメッセージをconsoleに表示

概要 Errorメッセージをconsoleに表示して何がおきているか確認する。 解決方法 for model in models: try: // 処理 print("success); except Exception as e: print("message : %s" % e) pass

【Python】AttributeError: 'dict' object has no attribute 'iteritems'

概要 以下のエラーが出たので対応。 AttributeError: 'dict' object has no attribute 'iteritems' 解決策 iteritems()からitems()にする。

【Python】NameError: name 'unicode' is not defined

概要 以下のエラーが出たので対処。 NameError: name 'unicode' is not defined 対処方法 pythonにおいてunicode型を使用した際にエラーが発生。 unicodeをstrにすれば解消する。 unicode<=>strの変換方法配下を参照してみると良い。 strとunicode

【Python】issubclassでTrueを期待するのにFalseが返ってくる

概要 issubclassを使っていて、Trueを期待するのにFalseが返って来て頭がおかしくなりそうになった。 時間をかけた割に大したことを得られなかった悲しさをこのブログにぶつける。 本題 ある復刻プロジェクトをやっているのだが、そのシステムではdynamoDBを…

【Laravel】TokenMismatchExceptionのエラーが出た

概要 LaravelをAPIサーバーとして利用したが、POST時にTokenMismatchExceptionと出てきたのでメモ。 対応方法 CSRFのチェックを外すためにapp\http\Middleware\VerifyCsrfToken.phpの中に以下を記載。 protected $except = [ 'api/*' ]; しかしこれはセキュ…

【Python】htmlファイルの改行とタブを削除するやつ

概要 htmlビルダーを利用して仕事をしているのだが複雑になってくると最終的に出力されるhtmlと、デザイナーが作ったこういう風に作ってください、というモックのhtmlとちゃんとあっているかを目で確認しないといけないのは非常に面倒である。Diffツールを使…