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 difference between end= and sep= in Python

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of what is the difference between end= and sep= in Python, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe that you will gain something after reading the difference between end= and sep= in this Python. Let's take a look.

End: the default is a newline, indicating what the two strings end with.

Eg: line wrap end= ""

Sep: the default is a space, indicating what division is used between two strings.

Eg: space sep= ""

Name = "W3Cschool" # can also specify any character manually, such as comma print ("your name:", name,sep= ",") # print default line wrapping # if you output the contents of multiple output statements to one line Yes: print ("your name:", end= ") print (" Thank you ", end=") # do not want to output anything end= "- No spaces print (" your name: ", end=") print ("Thank you", end= ")

Add: print (x, end=) and print (x, sep=) in python

Print (x, end=) for i in range (10): print (I)

Output result:

0 1 2 3 4 5 6 7 8 9

For i in range (10):

Print (I, end= "")

Output result:

0 1 2 3 4 5 6 7 8 9

The parameter end prints line breaks by default, that is, end = ""

Print (x, sep=)

Sep is used for print stitching.

Print ("hello", "world", sep= ":")

Print the results:

Hello:world

This is the end of the article on "what's the difference between end= and sep= in Python". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what is the difference between end= and sep= in Python". If you want to learn more, you are welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report