The default output of print in Python is line wrapping. If you want to achieve no line wrapping, you need to add a comma at the end of the variable.
Example:
#!/usr/bin/python # -*- coding: UTF-8 -*- x="a" y="b" # 换行输出 print x print y print '---------' # 不换行输出 print x, print y, # 不换行输出 print x,y
The execution result of the above example is:
a b --------- a b a b
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of How to print python output on only one line. For more information, please follow other related articles on the PHP Chinese website!