Let's look at the effect that the comma and the plus sign print separately in print.
Here take Python3 as an example
1 |
Print ("Hello" + "World") |
HelloWorld
1 |
Print ("Hello", "World") |
Hello
World
A plus sign is found here to concatenate strings and commas to concatenate strings with spaces.
Try the actions of different data types:
Typeerror:must is str, not int
Hello 123
The plus sign here shows a type error when the str type is added to the NUM type, the comma is concatenated properly and returns the string result.
Summary:
Plus +: The two sides can only be the same data type, in Python is mainly the existence of operators, and strings such as the addition of the type is only a built-in method in Python. Comma,: Here the comma more represents a connection with a space.
The difference between a comma and a plus sign in the print function in Python