Https://docs.python.org/3/library/functions.html#next
Bin () binary
Oct () octal
int () decimal
STR () string
Print (hex) i = Int (' One ', base=8) print (i) #============i = Int (' 0xe ', base=16) print (i) i=int (' 0b11 ', base=2) print (i) I =int (' 0o11 ', base=8) print (i) ==================================ord () converts a letter into a digital Chr () converts a number to a letter
T=ord (' a ')
Print (T,type (t))
n = chr (65)
Print (N,type (n))
Run results
<class ' int ' >
A <class ' str ' >
==================================
Random Verification code (with six digits and uppercase letters) import randomtemp= "" For I in range (6): num = Random.randrange (0,4) #生成0到3的随机数4种可能 & nbsp If num ==3 or num ==1: #1或3就生成数字 rad2 = Random.randrange (0,10) temp = temp + str (rad2) else: rad1=random.randrange (65,91) &nbs P temp +=CHR (rad1) #生成随机字母print (temp) =============================================dict () Generate dictionary list () list tuple () tuple int () digit str () string ============================================ operation Len () calculates the length sum () Sum eval () calculates Max () to find the smallest of min ()
T=max ([11,22,33])
Print (t)
N=min ([11,22,33])
Print (n)
M=len ([11,22,33])
Print (m)
Sum=sum ([11,22,33])
Print (sum)
Sum1=eval (' 1 + 2 + 3 ')
Print (SUM1)
Run results
33
11
3
66
6
==========================================
Isinstance () to determine if a string, array, tuple, dictionary, etc., is true for false false for true
ret = Isinstance ([11,22,33],str)
Print (ret)
Run result is false
ret = Isinstance ([11,22,33],list)
Print (ret)
Run result is true
=============================================================
Next () iterates back the next element until it runs out, stopiteration an error
S=iter ([11,22,33])
T=next (s)
Print (t)
T1=next (s)
Print (T1)
T2=next (s)
Print (T2)
T3=next (s)
Print (T3)
Run results
11
22.
33
Traceback (most recent):
File "h:/python17/s29.py", line 135, in <module>
T3=next (s)
stopiteration
========================
Globals () List global variables
Locals () Local variables
====================================
Zip ()
x=[1,2,3]
y=[4,5,6]
Zipped=zip (x, y)
Print (List (zipped))
X1,y1=zip (*zip (x, y))
Print (x1)
Print (y1)
Run results
[(1, 4), (2, 5), (3, 6)]
(1, 2, 3)
(4, 5, 6)
Python built-in functions