The next day, some basic built-in functions

There is also a role int

a="11"
i=int(a,base=2)
print(i)

denotes a base current of a few hexadecimal, and to a conversion of 10 hex

 

.bit_length method

age=3
zaiti=age.bit_length()
# .Center () method 
# I = "small" 
# TESE = i.center (10, "0") and the overall width Set # "small," centrally, on both sides is filled with 0 
# Print (TESE) 
# 
# casefold method : all variants lowercase 
# Aliez = "Zeyed" 
# i = Aliez.casefold () 
# Print (i) 
# capitalize method: capitalize the first letter 
# 
# COUNT method: to find the number of occurrences of the string sequence of 
# i = "11111111 " 
# Print (i.count (". 1 ", 3,5)) 
# number is a string containing the output sequence in the fourth to sixth elements 
# 
# endsWith () method to detect whether or not any end 
# startsWith () method can detect whether or not start with what 

# the find next to find from the beginning, to find the first to get his position, can be predetermined section 
# a = "fawhiojogjegj"
# Print (a.find ( "J",. 7,)) 

# the format method: a string replaces the placeholder value specified 
# zifuchuan = "I AM. 1 {}, Age {0}" This is the position determined replacing 
# zaiti zifuchuan.format = (. 19, "yangg") 
# Print (zaiti) 
# may be replaced by a label, 
#  
# isalnum () method can determine whether a string contains only letters and numbers
 
 

 


print (zaiti)

Can be expressed in binary represented the age need at least a few bits

 

Guess you like

Origin www.cnblogs.com/baizhige/p/11184234.html