How to wrap the output in Python print?

Guanhui
Release: 2020-06-19 11:36:15
Original
51304 people have browsed it

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!