python variables comma, meaning

Comma ,for generating a tuple of length 1

>>> (1)
1
>>> (1,)
(1,)
>>> 1,
(1,)

Thus the length of the required element of the tuple can be extracted from a ,simplified assignment

>>> a=(1,)
>>> b=a
>>> b
(1,)
>>> b,=a
>>> b
1

Finally printprint variable by ,continuous printing operation does not wrap not work in the python3

Python 3.7.3 (default, Nov 15 2019, 04:04:52) 
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 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

Guess you like

Origin www.cnblogs.com/azureology/p/12343730.html