Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

新增py3支持 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions modian.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
# -*- coding: utf-8 -*-
import setting
import requests
import json
import sys
# 消去https请求的不安全warning
# import urllib3
# urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
import urllib
import hashlib
reload(sys)
sys.setdefaultencoding('utf8')


# -------------------------------
Expand All @@ -22,8 +15,8 @@
def getSign(ret):
# 将字典按键升序排列,返回一个元组tuple
tuple = sorted(ret.items(), key=lambda e: e[0], reverse=False)
md5_string = urllib.urlencode(tuple)
md5_string += '&p=das41aq6'
md5_string = urllib.parse.urlencode(tuple).encode(encoding='utf_8', errors='strict')
md5_string += b'&p=das41aq6'
# md5计算 & 十六进制转化 & 根据规则从第6位开始取16位
sign = hashlib.md5(md5_string).hexdigest()[5: 21]
return sign
Expand Down