Fast solution to the non-newline instant output of print in Python _python

Source: Internet
Author: User

About the python2.x and 3.x to bring the print does not wrap the problem: Yesterday had a push text, using the end = definition, to solve the small horizontal problem, but because of the screen display problem, if the string length is too large, it will cause inconvenience. Two or more print to split the case, how to maintain the horizontal output, the general is at the end of the print with a comma (,) but under 3.x, then no, need to use end = "(something)", some signs like,. ; ' also can put a word or str in '.

Example:

############################################
end1 = "J"
end2 = "U"
end3 = "s"
End4 = "T"
End5 = "T" C6/>end6 = "E"
End7 = "s"
End8 = "T"
print (end1 + end2 + end3 + end4,end = "")
print (End5 + End6 + End7 + End8)
############################################
Explain: You can, I put a space
between ""
There is something in your screens:
Just test all the codes is run in
python 3.2,if you write the Cod Es in Pythons 2.x,like python2.7,
 
 
##################################################
end1 = "J"
End2 =  "U"
end3 = "s"
End4 = "T"
End5 = "T"
End6 = "E"
End7 = "s"
End8 = "T"
print (End1 + end2 + End3 + end4,)
print (End5 + end6 + End7 + end8)
#################################################
That's all,in python 2.x
 
 
 
 
so the differences
are: 3.2 end = ""
2.7,

Above this python in the print of the instant output fast solution is small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.

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.