As follows:
Just add str(i) in front of i
Supplementary extension: python connection string and number
Python connection string and number problem:
The first thing to say is that python is a strongly typed language. If you connect a string and a number directly, you will get an error:
TypeError: must be str, not int
Here is an example of ours:
a = 33
b = “33”
c = a + b
If you want to connect a number with a string, you can convert the number to the form of a string through the str method, and then do the connection operation.
For example, c = str(a) + b
The final result is: 3333
The above python implementation of string and number splicing is all the content shared by the editor, I hope to give you a reference.
Recommended Posts