Home  >  Article  >  Backend Development  >  How to wrap the output in Python print?

How to wrap the output in Python print?

Guanhui
GuanhuiOriginal
2020-06-19 10:08:2451237browse

How to wrap the output in Python print?

Python print How to wrap the output?

Using the print function in Python, you can add the "\n" newline character to the output content to achieve newline output. "\n" is a computer language expression, and its function is to jump to For a new line, if you want to wrap it in a Windows system, you need to add "\r" at the end of "\n".

Sample code

class PrintTable(object):
    def __init__(self):
        print('开始打印 9X9 乘法表格')
        self.print99()

    def print99(self):
        for i in xrange(1, 10):
            for j in xrange(1, i+1):
                print('%d * %d =%2s ' %(j,i,i*j)),
            print('\n')

if __name__ == '__main__':
    pt = PrintTable()

Other escape characters

How to wrap the output in Python print?

Recommended tutorial: "Python Tutorial"

The above is the detailed content of How to wrap the output in Python print?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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