Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the function of commas in Python

Shulou Source: shulou.com Published: 2022-06-01 16:03:13 10月04日 Update

This article introduces what is the role of commas in Python, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

1. The use of commas in parameter passing

There is not much confusion in this case, which is the comma between parameters when parameters or arguments are passed.

For example, def abc (aformab) or abc (1mem2)

two。 The use of commas in type conversion-mainly tuple conversion

For example:

> axi11

> b = (a)

> > b

eleven

> b = (a,)

> > b

(11,)

> b = (apr 22)

> > b

(11, 22)

> b = (a, pr 22,)

> > b

(11, 22)

You can see that only when there is only one element in the b tuple, a comma is needed to convert to the tuple type.

3. The ingenious use of comma in output statement print

Example:

> for i in range (0pc5):

... Print i

...

0

one

two

three

four

> for i in range (0pc5):

... Print i

...

0 1 2 3 4

About what the role of commas in Python is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Comma function content parameter only time more type help yes in between in example element interest place magic use boy buddy that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Linux Docker MariaDB Shulou Technology