Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of commas in Python

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report