The basic data type conversion python

Data type conversion

  1. Can be converted to a digital numeric string may be converted to a string, but when a particular type of non-numeric string, is converted into digital integer result can not be estimated
  2. String can be converted to a Boolean value, only the '' means to false, the rest are true, note '' is not a string of spaces
  3. Integer can also be converted to a Boolean value, 0 represents only false, the rest are true
  4. Can be converted to Boolean strings and numbers, true is 1, 'true' false is 'false', 0

 

Small knowledge:

Digital converter to a string # 
# = Val 666
# STR Val = (Val)
# Print (Val)
# string-to-digital
# Val = "666"
# Val = int (Val)
# Print (Val)

# digital-to Boolean 0 It is to false
# 666 = val1 is
# val2 = BOOL (val1 is)
# Print (val2)


# transfected Boolean string "" as Fase
# = val1 is ". 1"
# val2 = BOOL (val1 is)
# Print (val2)

# other Boolean transformation

" ""
val1 is True =
val2 = STR (val1 is)
Print (val2)

to true is 1, false is 0
val1 is True =
val2 = int (val1 is)
Print (val2)
"" "
# value = 10 or 2
# print(value)
#
# value = 0 or 2
# print(value)
#
# value = 1 or 0
# print(value)
For and, if they value = 1 and 9 such a case if the first value is converted to a boolean value True, the second value = value. If the first value is converted to a boolean value False, then the first value = value.































And if there are a plurality of conditions, the above-described process from left to right.
Example:
V1 =. 9. 1 and
V2 = 0. 1 and
V3 = 0. 7 and
V4 = 0 and ""
V5 = 0 and. 9. 1 and


# integrated
# look and look or
#. 1 and V1 = 0. 9 and. 6 or
# print (v1)

Guess you like

Origin www.cnblogs.com/sundy08/p/11792525.html