python3中引入扩展包时的几个注意事项

一、python3引入urllib2

python3的urllib2与urllib合并了,使用时需要使用

import urllib.request

打开:

response = urllib.request.urlopen("网页地址")

二、python 获取md5

#使用python 库  求MD5
import hashlib
#求字符串MD5
md5 = hashlib.md5('字符串').hexdigest()
#求文件md5
file = open('文件''rb')
md5 = hashlib.md5(file.read())hexdigest()
file.close()
#生成sig
        signature = self.AccountSid + self.AccountToken + self.Batch;
        sig= hashlib.md5(signature.encode(encoding='UTF-8')).hexdigest().upper()

--------------------

 

posted on 2020-03-16 15:32  闪亮的金子  阅读(163)  评论(0编辑  收藏  举报