What is not much to say, look at the source code
# ! / Usr / bin / env Python # - * - Coding: UTF-8 - * - # @author: shenqiang # for encrypting data processing platform ah '' ' interface to the automation needs and questions: "1. In accordance with the request key parameters ascill -value sort code format, the parameter name - request parameter uncertainties - how to sort 2. in the first step of splicing the tail of the resulting string key - name = shenqiang & age = 28 & address = nanjing & sex = boy + key 3 after sorting , the parameters of the request are MD5 encryption " - hashlib solutions (core: problem-solving ideas) 1. request parameter uncertainty ---> dynamic parameters args *, ** kwargs 2. how to sort ---> sorted () 3. the key request address tail may be spliced urllib parse the encrypted 4.hashlib '' ' from urllib Import parse Import hashlib DEF dataSign (Secure = 'shenqiang ' , * args, ** kwargs): ' '' of the sort key is the dictionary '' ' dict2 = dict (the sorted (kwargs.items (), key = the lambda Item: Item [0])) ' '' to splicing url '' ' str1 = parse.urlencode (dict2) + Secure ' '' for the MD5 '' ' # instantiated MD5 MD = hashlib.md5 () md.update (str1.encode ( ' UTF-. 8 ' ) ) return md.hexdigest () '' ' DATA2 parameter uncertainty ' '' DATA2 = { "a":"2","c":"1","b":"3"} print(dataSign(**data2))