The precision determines the maximal number of characters used. strHello = 'Hello Python' print strHello #输出结果:Hello Python #直接出字符串 1.格式化输出整数. There are similar methods str.ljust() and str.center(). Python print() The print() function prints the given object to the standard output device (screen) or to the text stream file. String (converts any Python object using repr()). If the object or format provided is a unicode string, the resulting string will also be unicode. (Note that in the first example, one space between each column was added by the way print works: by default it adds spaces between its arguments.). The precision determines the maximal number of characters used. Although this tutorial focuses on Python 3, it does show the old way of printing in Python for reference. ‘%’
The message can be a string, or any other object, the object will be converted into a string before written to the screen. ‘s’ String (converts any Python object using str()). There were a number of good reasons for that, as you’ll see shortly. python print也支持参数格式化,与C言的printf似, strHello = "the length of (%s) is %d" %('Hello World',len('Hello World')) print strHello #输出果:the length of (Hello World) is 11 2.格式化输出16制整数

The print() function prints the specified message to the screen, or other standard output device.. Note: print() was a major addition to Python 3, in which it replaced the old print statement available in Python 2. This example demonstrates the str.rjust() method of string objects, which right-justifies a string in a field of a given width by padding it with spaces on the left. Python print() function The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement. Definition and Usage.