Python print for non-line wrapping

Source: Internet
Author: User

I. Environment and BACKGROUND

WINOWS10 + python2.7 + python3.5

Need to use print in python2.7 and no line break


Ii. Methods of Use

1. Add a comma at the end

print "Hello World",

Problem: After the output of the result will be more a space , this space put me pit 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0065.gif "alt=" j_0065. GIF "/>

2. Using the SYS module

Import sys sys.stdout.write ("Hello World") Sys.stdout.flush ()


3. Using the Python 3.x version of print

The print function in version 3.x adds an end parameter with a default value of end= ' \ n '

Print ("Hello World", end= ")


This article is from the "Snow Dancer" blog, please be sure to keep this source http://happytree007.blog.51cto.com/6335296/1891902

Python print for non-line wrapping

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.