如何使用 Python 打印多行文本 [英] How to print multiple lines of text with Python

查看:78
本文介绍了如何使用 Python 打印多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想在 Python 中打印多行文本而不为每一行键入 print(''),有没有办法做到这一点?

If I wanted to print multiple lines of text in Python without typing print('') for every line, is there a way to do that?

我将它用于 ASCII 艺术.

I'm using this for ASCII art.

(Python 3.5.1)

(Python 3.5.1)

推荐答案

您可以使用三重引号(单 ' 或双 "):

You can use triple quotes (single ' or double "):

a = """
text
text
text
"""

print(a)

这篇关于如何使用 Python 打印多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆