Home  >  Article  >  Backend Development  >  Is sep a function in Python? How to use it?

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

angryTom
angryTomOriginal
2020-02-11 09:24:3712395browse

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

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

can also be changed to commas as intervals.

print("abc", "uuu", "oop", sep = ", ")
# abc,uuu,oop

Of course special symbols are also acceptable.

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

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

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

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!

Statement:
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