Why does python print() print without line breaks?

爱喝马黛茶的安东尼
Release: 2019-12-28 11:37:50
Original
36839 people have browsed it

Why does python print() print without line breaks? There are differences in different versions of python, and there are obvious differences between Python2 and Python3. Let me introduce to you the differences between the two.

Why does python print() print without line breaks?

In Python2.x

The output in python2.x defaults to newline. In order to suppress newline, you can print at the end Add a comma

Recommended manual:Python basic introductory tutorial

Why does python print() print without line breaks?

##Related recommendations: "

Python Video Tutorial"

In Python3.x

In python3, print becomes a function, this This syntax won't work.

Recommended manual: Python 3 Tutorial
We can use print(x, end="")

end= "" prevents the output from wrapping.

The content between the double quotes is the ending content. It can be a space or other characters. The default is line break

Why does python print() print without line breaks?

Related articles recommend: ​         1.
How to wrap lines when writing in python 2.
How to wrap python print
Related video recommendations: ​ ​ ​ 1.
2019python self-study video2.
Python Web Getting Started Video Tutorial3.
python Getting Started Video Tutorial

The above is the detailed content of Why does python print() print without line breaks?. 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