Python implements string and number splicing

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

Python implements string and number splicing
Python string
Python implements username and password verification
Python string
Python basic syntax and number types
Python implements singly linked lists and dictionaries
Python string manipulation
Python and Go
Python realizes horizontal and vertical splicing of pictures
Python introspection and reflection
Python implements Super Mario
Python implements tic-tac-toe game
Python implements tic-tac-toe game
[python] python2 and python3 under ubuntu
Python implements man-machine gobang
Python implements Tetris game
Python implements image stitching
Python implements minesweeper game
Python implements scanning tools
Python deconstruction and packaging
Python3 configuration and entry.md
Str string in Python
Python implements threshold regression
Python implements minesweeper games
Python implements electronic dictionary
Python implements guessing game
Python | An article to understand Python list, tuple and string operations
Python automated operation and maintenance 2
Python introduction and environment installation
Python know crawler and anti crawler
Python implements WeChat airplane game
centos7 install python3 and ipython
Python implements word guessing game
How Python converts string case
Python implements a guessing game
Python implements parking management system
Python implements digital bomb game
Python implements TCP file transfer
ubuntu18.04 compile and install python3.8
Python numpy implements rolling case
Centos 6.10 reinstall python and yum
OpenCV Python implements puzzle games
Python implements simple tic-tac-toe game
Python open read and write
Python interview questions: string concatenation
Python implements password strength verification
Python implements car management system
CentOS7 install python3 and pip3
Python implements code block folding
Python implements panoramic image stitching
Python automated operation and maintenance 1
Python data structure and algorithm
Python multi-process and multi-thread basics
Python implements SMTP mail sending
Python implements multi-dimensional array sorting
How Python implements FTP function
Python implements mean-shift clustering algorithm
CentOS 6.9 compile and install python
Python implements verification code recognition
Python implements gradient descent method
Python implements text version minesweeper