Li = [' Alex ', ' Eric ', ' Roman ']
For I in Enumerate (li,10):
Print (i)
Results:
(' Alex ')
(One, ' Eric ')
(' Roman ')
Conclusion: Enumerate is convenient for adding a self-increment sequence number to an element
Print (Ord (' C '))
Print (CHR (99))
Results:
99
C
Conclusion: Ord can convert a character to an ASCII code, and CHR can convert ASCII to a string
a1 = "[[+], [3,4], [5,6], [7,8], [9,0]]"
B1 = eval (A1)
Print (B1)
Print (Type (B1))
Results:
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 0]]
<class ' list ' >
Conclusion: string conversion to List
A2 = "([up], [3,4], [5,6], [7,8], [9,0])"
b2 = eval (A2)
Print (B2)
Print (Type (b2))
Results:
([1, 2], [3, 4], [5, 6], [7, 8], [9, 0])
<class ' tuple ' >
Conclusion: string conversion to Ganso
A3 = "{1: ' A ', 2: ' B ', 3: ' C '}"
B3 = eval (A3)
Print (A3)
Print (Type (B3))
Results:
{1: ' A ', 2: ' B ', 3: ' C '}
<class ' Dict ' >
Conclusion: string conversion to Dictionary
Li = [11,22,33,44]
# New_li = List (map (lambda X:x+100,li))
# Print (Type (new_li))
# Print (New_li)
def func (x):
x = x+100
return x
New_li = List (map (Func,li))
Print (New_li)
Results: [111, 122, 133, 144]
Conclusion: The map function will process the input to the output, one to the other, and the map first parameter is the function
Li = [11,22,33,44]
def func (x):
If x>22:
Return True
Else
Return False
F_li = List (filter (Func,li))
Print (F_li
Results: [33, 44]
Conclusion: The filter function can be used for filtering operation through function.
Python intrinsic functions