为了削减反复的情况,你可以应用这两个函数。
注册Shutdown函数
- import hmac,hashlib
- key='1'
- data=http://developer.51cto.com/art/201706/'a'
- print hmac.new(key, data, hashlib.sha256).hexdigest()
- m = hashlib.sha1()
- m.update("The quick brown fox jumps over the lazy dog")
- print m.hexdigest()
- # c6e693d0b35805080632bc2469e1154a8d1072a86557778c27a01329630f8917
- # 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
序列化
你曾经须要将一个复杂的变量存储在数据库或文本文件中吧?你不须要想一个独特的办法将数组或对象格转化为式化字符串,因为Python已经供给了此功能。
- import pickle
- variable = ['hello', 42, [1,'two'],'apple']
- # serialize content
- file = open('serial.txt','w')
- serialized_obj = pickle.dumps(variable)
- file.write(serialized_obj)
- file.close()
- # unserialize to produce original content
- target = open('serial.txt','r')
- myObj = pickle.load(target)
- print serialized_obj
- print myObj
- #output
- # (lp0
- # S'hello'
- # p1
- # aI42
- # a(lp2
推荐阅读
媒介<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> 简单工作简单做-宽度自适应所谓宽度自适应严格来说是一种PC端的自适>>>详细阅读
地址:http://www.17bianji.com/lsqh/35585.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示