upgrade python 2to3

1154 ワード

python2.7->python3.5(3.6)
djangoのmysqlドライバライブラリ
python2.7: $ sudo pip install MySQLdb python3.4: $ sudo pip install PyMySQL
djangoのインストール手順は同じです.そして自分のサイトでpyファイルに2つの文を追加します.
settings.py
import pymysql
pymysql.install_as_MySQLdb()

    storage_engine -》default_storage_engine


crypto
crypto:use python crpyto.py install m2crypto for python3 git clone -b python3 https://gitlab.com/m2crypto/m2crypto && cd m2crypto && python setup.py build && python setup.py install
     #crypto.Init()
     #valid, rsp_data['data'] = crypto.encrypto(json.dumps(data).encode('utf-8'))
     -》
     rsp_data['data'] = crypto.encrypto(json.dumps(data).encode('utf-8'))

dict
1.iteritems() -> items() 2. has_key() -> in
urllib
try:
    from urllib.parse import quote, unquote, urlencode
except:
    from urllib import quote, unquote, urlencode

文字列
strbytes mytoken.pyでエンコードの問題get_が発生しましたtokenはbytesが必要な場所でencode(encoding='utf-8')を使用し、strが必要な場所でdecode(encoding='utf-8'に戻る