# li = [11,22,33,44]
# def F1 (ARG):
# Arg.append (55)
# # Li = F1 (LI)
# F1 (LI)
# Print (LI)
# It's not important.
# Whether it can be executed is called
# def F1 ():
# Pass
# # F1 ()
# F2 = 123
# # F2 ()
# Print (callable (F1))
# Print (callable (F2))
# callable ()
# ascil Code Conversion list to convert the corresponding relationship
# Convert numbers into letters
# r = Chr (65)
# print (R)
# A
# Convert letters into numbers
# n = Ord ("a")
# print (n)
# 97
#生成字母随机验证码
# import Random
# li = []
# for I in range (6):
# temp = Random.randrange (65,91)
# c = chr (temp)
# Li.append (c)
# result = "". Join (LI)
# Print (Result)
# Generate random Numbers
# import Random
# 1 <= i <5
# i = random.randrange (1,5)
# i = Random.randrange (65,91)
# c = Chr (i)
# Print (c)
# Generate letters
# import Random
# li = []
# for I in range (6):
# temp = Random.randrange (65,91)
# c = chr (temp)
# Li.append (c)
# result = "". Join (LI)
# Print (Result)
#生成字母数字, randomly generate digital letters
# import Random
# li = []
# for I in range (6):
# If I ==2 or I ==4:
# num = Random.randrange (0,10)
# li.append (num)
# Else:
# temp = Random.randrange (65,91)
# c = chr (temp)
# Li.append (c)
# result = "". Join (LI)
# Print (Result)
#生成字母数字, randomly generated number of digits without limit
# import Random
# li = []
# for I in range (6):
# r = Random.randrange (0,5)
# if R ==2 or R ==4:
# num = Random.randrange (0,10)
# li.append (num)
# Else:
# temp = Random.randrange (65,91)
# c = chr (temp)
# Li.append (c)
#
# result = "". Join (LI)
# Print (Result)
# compile () Compile code
# python s1.py
# 1, read file contents, str to memory
# 2, Python inside, the string-"compiled into-" special code
# 3, Code execution
# s = "Print (123)"
# Compile single (one-line), eval (expression), exec (python)
# Compile the string into Python code
# r = Compile (s, "<string>", "exec")
# print (R) #<code object <module> at 0x101b1f5d0, file ' <string> ', line 1>
# exec executes Python code
# exec (r) # 123
# eval ()
# Execute Python code, receive: Code or string
# exec ("7+8+9")
# eval executes an expression and gets the result
# ret = eval ("7+9+8")
# Print (ret)
# Execute Python code, continue to receive code or string
# exec ("7+9+8")
#执行表达式 and get the results
# ret = eval ("7+9+8")
# Print (ret)
# Quick view of what features the object provides
# Print (dir (dict))
# View Help
# Help (list)
# Total: 97, show 10 per page, how many pages
# r = Divmod (97,10)
# print (R) Quotient 9 of 7
# r = Divmod (100,10)
# print (r[0]) merchants
# print (r[1]) remainder
# s = "Alex" Object, "alex" = + str
# s = [11,11,11]
# isinstance is used to determine if an object is an instance of a class
# r = isinstance (s,list)
# print (R) returns True
# Filter,map
# def F1 (args):
# result = []
# for item in args:
# if item > 22:
# Result.append (item)
# return result
#
# li = [11,22,33,44,55]
# ret = F1 (LI)
# print (ret) 33,44,55
# Filter (Functions, objects that can be iterated)
# def F2 (a):
# if a > 22:
# return True
# li = [11,22,33,44,55]
# ret = filter (F2,li)
# Print (list (ret))
# inside the filter, loop the second parameter
# result = []
# for item in second argument
# r = First parameter (item)
# if R:
# result (item)
# return result
# filter, loop the second argument, let each loop element execute the function (the first argument), if the function returns a value of true, indicates that the element is valid
# ret = filter (F2,li)
# Print (list (ret))
# Auto Return
# f1 = Lambda a:a >30
# ret = F1 (90)
# print (ret) True
# The Filter function returns true to add elements to the result
#
# li = [11,22,33,44,55]
# result = Filter (lambda a:a > 33,li)
# print (list result)
# li = [11,22,33,44,55]
# def F1 (args):
# result = []
# for I in args:
# result.append (100+i)
#
# return result
# r = F1 (LI)
# Print (list (R))
# map adds the function return value to the result
# li = [11,22,33,44,55]
# map (function, iterative object (something that can be used for looping))
# def F2 (a):
# return a + 100
# result = Map (F2,li)
# result = Map (lambda a:a +200,li)
# print (list result)
# result = Map (lambda a:a + 200,li)
# print (list result)
# len
# s = "Li Jie"
# print (len (s))
#
# s = "Li Jie"
# b =bytes (s,encoding= ' utf-8 ')
# print (len (b))
# 2 of the 10-time Square
# r = Pow (2,10)
# print (R)
# reverse
# li = [11,22,1,1]
# Li.reverse ()
# Reversed (LI)
# Print (LI)
# rounding
# r = Round (1.8)
# print (R)
# slices
# s = "Sssssssssss"
# print (S[0:2:2])
# sort
# li = [11,22,3,1,2]
# Li.sort ()
# Print (LI)
# zip
# L1 = ["QQ", 11,22,33]
# L2 = ["AA", 11,22,33]
# l3 = ["zz", 11,22,33]
# r = Zip (L1,L2,L3)
# # Print (list (R))
# temp = List (r) [0]
# ret = '. Join (temp)
# Print (ret)
Python Learning Note 3