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