python2.7->python3.5(3.6)
django的mysql 驱动库
python2.7:
$ sudo pip install MySQLdb
python3.4:
$ sudo pip install PyMySQL
django的安装步骤一样。然后在自己的站点init.py文件中加入两句话:
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
字符串
str<->bytes
mytoken.py里面出现编码问题
get_token
需要bytes的地方使用encode(encoding='utf-8'),需要 str的地方 再转回 decode(encoding='utf-8'