Time module:
>>>Import Time>>>Time.time<built-inchfunction time>>>>time.time ()1473837803.320634>>>time.localtime () time.struct_time (Tm_year= ., tm_mon=9, tm_mday= -, tm_hour= the, tm_min= at, tm_sec= -, tm_wday=2, tm_yday=258, tm_isdst=0)>>>time.ctime ()'Wed Sep 15:25:17'>>> Time.strftime ('%y-%m-%d%h:%m:%s') '2016-09-14 15:35:30'
Serialization and JSON:
Serialization: The process of encrypting an object (list, meta-ancestor, dictionary) in a special binary way that can serialize any data type.
JSON: the memory of the data of the Jason, the principle and serialization of the same
difference:Pickle can only be used in Python; JSON supports all languages, only regular data types can be serialized; Pickle serialized data does not visually reveal data content
>>> name_dict = {'name':'pingy',' Age': -}>>>Import JSON>>>Import Pickle>>>json.dumps (name_dict)'{"Age": +, "name": "Pingy"}'>>>Pickle.dumps (name_dict) b'\x80\x03}q\x00 (x\x03\x00\x00\x00ageq\x01k\x14x\x04\x00\x00\x00nameq\x02x\x05\x00\x00\x00pingyq\x03u.'MD5:
= hashlib.md5 () ha.update ('admin') #md5加密print (Ha.hexdigest ())
Generate random Number:
Random : Stochastic random.random (): randomly generates 0-1 decimal random.randint (1,5): Randomly generated 1- Integers in the range 5 (including 1 and 5) random.randrange (1,3): Integers in a randomly generated 1-3 range (excluding 3)
= [] for in range (6): if i = = Random.randint (1, 9 ): code.append (str (random.randint (1,9))) Else : = Random.randint (+) #A-Z code.append (chr (temp)) print (' . Join (code))
Reflection: Importing a module as a string and executing a function in the form of a string
temp = 'mysqlserverhelper'count'= __import__ (temp) = GetAttr (module,'count') #以字符串的形式执行函数print (function)
Python:time Module & Serialization &md5& generate random Number & reflection