10.Number cast

# ### casts = Number The> (int a float BOOL Complex) 
 
var1 = 13 is 
var2 = 99.99 
var3 = True 
var3_1 = False 
var4. 4 + = 1J 
var5 = "123321" 
var6 = "Hello 123" 
 
 
 
# cast data to an integer int (int float Boolean pure numeric string) 
# int 
RES = int (var2) 
Print (RES) 
# True 1 False strong strong rotation is transferred integer is the integer 0 
RES = int (var3) 
RES = int (var3_1) 
Print (RES) 
RES = int (var5) 
Print (RES, type (RES)) 
# RES = int (var6): error 
# Print (RES, type (RES)): error 
 
 
 
# a float (whole float Boolean type purely numeric string) 
RES = a float (var1) 
RES = a float (var3) # .0 plus decimal become 
res = float (var3_1) # 0.0
RES = float # (var4) Convert For Complex # CAN not to float 
RES = float (var5) # 123,321.0 
Print (RES) 
 
 
# Complex (int float boolean pure numeric string plural) 
RES = Complex (var1) # 13 is + 0j 
RES = Complex (var2) # (99.99 + 0j) 
RES = Complex (var3) # (. 1 + 0j) 
RES = Complex (var3_1) # 0j 
RES = Complex (var5) # (123321 + 0j) 
Print (RES ) 
 
 
 
# BOOL (data container types / Number of data types are either True or False) 
RES = BOOL (var6) 
RES = BOOL (var4) 
RES = BOOL ([l, 2,3]) 
Print ( "<!!! > ") 
Print (RES) 
" "" ***** five stars ***** 
Boolean false ten cases: 
0, 0.0, false, 0j, "", [], (), the SET (), {}, None 
None representation system is a key blank, nothing, to do the initial value is generally 
"" "
res = None 
Print (RES, of the type (RES))

  

Guess you like

Origin www.cnblogs.com/eliwen/p/10967679.html