There are many types of data, such as numeric values and characters, such as 6 and a. Characters need to be enclosed in double quotes. The results of the following examples are different. Values will be added and characters will be connected.
print(6+6)
print("6"+"6")
结果
To view the data type, you can use the "type(xxx)" instruction, and then print it out with the print instruction
print(6+6)
print("6"+"6")
print(type(6))
data conversion
num = "6" The code like
print(4 + num)
will report an error, because there are both numbers and characters in the parentheses, we need to unify the data in the parentheses
num = "6"
print(4 + int(num))
int is a function of numerical conversion, the form is int (XXX), which will force the characters in parentheses to be converted into numerical values, so the above code will operate normally
str is a character conversion function. . . .
num = "6"
print(str(4)+ num)
python is a strongly typed, dynamically changing language