Recently, I've been working on a comma problem with python, and I haven't figured it out today.
1. Use of commas in parameter passing:
This is not much to say that there is nothing to be confused about when a parameter or argument is passed the comma between the arguments
e.g. DEF ABC (A, b) or ABC
2. The use of commas in type conversions is mainly the conversion of tuples
For example:
>>> a=11
>>> b= (a)
>>> b
11
>>> b= (A,)
>>> b
(11,)
>>> b= (a,22)
>>> b
(11, 22)
>>> b= (a,22,)
>>> b
(11, 22)
It can be seen that a comma is required to convert to a tuple type when there is only one element in the B-tuple
3. The magic of the comma in the output statement print:
Example:
>>> for I in Range (0,5):
... print I
...
0
1
2
3
4
>>> for I in Range (0,5):
... print I,
...
0 1 2) 3 4
It is obvious that the print statement defaults to a newline followed by a comma followed by a newline that becomes a space
What is the function of commas in python?