# integer3# = 3# There's nothing unexpected about arithmetic #1 +1# = 28-1# = 710 *2# = 20# but with the exception of division,are automatically converted to floating point numbers 35/5# = 7.05/3# = 1.6666666666666667# The result of integer division isRounding down 5//3# = 15.0//3.0# = 1.0 # Floating-point numbers are also available-5//3# = 2-5.0//3.0# =-2.0# The results of floating-point numbers are also floating-point numbers3 *2.0# = 6.0# modulo removal7%3# = 1# x Y-square2**4# = 16# The precedence is determined with parentheses (1 +3) *2# = 8# Boolean valueTrueFalse# Use not to take non-NotTrue# = FalseNotFalse# = True# logical operators,Note that both and and or are lowercase TrueandFalse#=> FalseFalseOrTrue#=> True# integers can also be used as Boolean values0and2#=> 0-5Or0#=>-50 = =False#=> True2 = =True#=> False1 = =True#=> True# judging equality with = =1 = =1# = True2 = =1# = False# Use! = To determine the unequal1! =1# = False2! =1# = True# Compare Size1 <10# = True1 >10# = False2 <=2# = True2 >=2# = True# Size comparison can be linked up!1 <2 <3# = True2 <3 <2# = False# strings can be used with a single-cited double-lead"This is a string."' This is also a string '
# Escape string with escape character \
' I\ ' m \ "Ok\"! ' # = I ' M "OK"!
#\ nRepresents a line break,\ tRepresents a tab character,\\Represents \ Itself
Print ("\\\t\\") # = \ \ \
# raw String.r ""The string in the expression "" is not escaped
Print (R "\\\t\\") # = \\\t\\
# Connect strings with plus sign"Hello" +"World!"# = "Hello world!"# string can be used as a list of characters"This is a string" [0]# = ' T '# with. FormatTo format the string' {} can be ' {} '. Format ("Strings","interpolated") # = ' strings can be interpolated '# you can repeat parameters to save time"{0} be nimble, {0} is quick, {0} jump over the {1}". Format ("Jack,""Candle stick")# = "Jack be nimble, Jack is quick, Jack jump over the candle stick"# If you don't want to count the arguments, you can use the keyword"{name} wants to eat {food}". Format (name="Bob," food=."Lasagna")# = "Bob wants to eat lasagna"# If your Python3 program is running under Python2.5, you can also use the old format syntax"%s can be%s the%s" "% ("Strings","Interpolated","old") # = ' strings can interpolated the old '# none is an objectNone# = None# when compared with None do not use = =, to use is. is is used to compare whether two variables point to the same object . "etc" is none # = False none is none # = True# none,0, empty string, empty list, empty dictionary are all considered false . All other values are true.
bool (0) # = False bool (
# = false bool ([])
# = False BOOL ({}) # = False
Python3 primitive data types and operators