python与django版本更新

本篇记录的是从python2.7,django1.7.1升级到python3.8.1,django3.0.5遇到的一些问题。


FileResponse

New in Django 1.7.4.

from django.http import FileResponse

utf-8编码

#python2
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
#python3
Python3字符串默认编码unicode, 所以sys.setdefaultencoding也不存在了。

urllib2库

urllib — URL 处理模块
urllib2 在 python3.x 中被改为 urllib.request
参考

urllib2 是 Python2.7 自带的模块(不需要下载,导入即可使用)
urllib2 官方文档:https://docs.python.org/2/library/urllib2.html
urllib2 源码:https://hg.python.org/cpython/file/2.7/Lib/urllib2.py

No module named ‘httplib’

Python 2.x中的"httplib"模块在Python 3.x中变成了"http.client"。


cookielib库

python3中为http.cookiejar。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值