Is sep a function in Python? How to use it?

angryTom
Release: 2020-02-11 16:12:38
Original
12408 people have browsed it

Is sep a function in Python? How to use it?

Is sep a function in Python? How to use it?

sep in Python is not a function, it is a parameter of the print function, used to define the interval symbol between output data.

The specific usage is as follows:

When printing multiple strings at the same time, each string will automatically use spaces as the interval between each string by default.

print("abc", "uuu", "oop")
# abc uuu oop
Copy after login

If you add sep = at the end of multiple strings, you can change the interval. For example, here we change it to no interval.

print("abc", "uuu", "oop", sep = "")
# abcuuuoop
Copy after login

can also be changed to commas as intervals.

print("abc", "uuu", "oop", sep = ", ")
# abc,uuu,oop
Copy after login

Of course special symbols are also acceptable.

print("abc", "uuu", "oop", sep = " & ")
# abc&uuu&oop
Copy after login

If you use \n, it will wrap automatically as usual.

print("abc", "uuu", "oop", sep = " \n")
# abc
# uuu
# oop
Copy after login

Many python training videos are all on the python learning network. Welcome to learn online!

The above is the detailed content of Is sep a function in Python? How to use it?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template