Python learning path: day4; python path: day4
Some common built-in functions:
Built-in function 1:
# Callable () # Check whether the function can be called. True and Falsedef f1 () are returned: pass # f1 () # f2 = 123 # f2 () can be called () # This cannot be called print (callable (f1) # It can be called print (callable (f2) # It cannot be called TrueFalse
Callable ()
# View the corresponding ascii code # ord () convert ASCII to a number # chr (), on the contrary, convert the number to ASCIIr = chr (65) print (r) # An = ord ("a") print (n) #97A97
Chr () and ord ()
# Random verification code import random # Add random verification code module li = [] for I in range (6): # loop temp = random. randrange (65, 91) # Return a random number c = chr (temp) in the set of the specified incremental base # convert the number to ASCII, which is originally a number, so convert it to uppercase letters, because the ASCII value of-91 is an uppercase letter li. append (c) # add each converted ascii to the list result = "". join (li) # Use the join method to convert the list to print (result) # random output at a time # input_li = input ("input li:") # if input_li = result: # print ("successfully logged on") # The following is a modified version # v2. The modified version can contain random numbers import randomli = [] for I in range (6): r = random. randrange (0, 4) # returns a random number if r = 2 or r = 4: # if the returned random number is equal to 2 or 4, let him continue with the next operation num = random. randrange (0, 10) li. append (str (num) # Add randomly generated values to the li list using strings. else: temp = random. randrange (65, 91) c = chr (temp) li. append (c) result = "". join (li) print (result) DYHVPI2QMTCM
Generate random Verification Code
Built-in function 2:
Last Update Time: 2017-11-30-18:43:02