python - 打印函数反斜杠消失Python 3

标签 python printing

游戏结束时的反斜杠消失了,如何保持它们可见?

__author__ = 'daniel'
# Game Over 2.0
# demonstrates the use of quotes in strings

print ("Program 'Game Over' 2.0")

print ("Same","message","as before")

print ("Just",
       "a bit",
       "bigger")

print ("Here", end=" ")
print ("it is.....")

print(
        """
         _____       ___       ___  ___   _____
        /  ___|     /   |     /   |/   | |  ___|
        | |        / /| |    / /|   /| | | |__
        | |  _    / ___ |   / / |__/ | | |  __|
        | |_| |  / /  | |  / /       | | | |___
        \_____/ /_/   |_| /_/        |_| |_____|

         _____   _     _   _____   _____
        /  _  \ | |   / / |  ___| |  _  \
        | | | | | |  / /  | |__   | |_| |
        | | | | | | / /   |  __|  |  _  /
        | |_| | | |/ /    | |___  | | \ \
        \_____/ |___/     |_____| |_|  \_\

        """
     )

input("\n\nPress the enter key to exit.")

最佳答案

'\' 字符被视为转义字符。使用 r 前缀将其视为原始字符串文字

print(
       r"""
         _____       ___       ___  ___   _____
        /  ___|     /   |     /   |/   | |  ___|
        | |        / /| |    / /|   /| | | |__
        | |  _    / ___ |   / / |__/ | | |  __|
        | |_| |  / /  | |  / /       | | | |___
        \_____/ /_/   |_| /_/        |_| |_____|

         _____   _     _   _____   _____
        /  _  \ | |   / / |  ___| |  _  \
        | | | | | |  / /  | |__   | |_| |
        | | | | | | / /   |  __|  |  _  /
        | |_| | | |/ /    | |___  | | \ \
        \_____/ |___/     |_____| |_|  \_\

        """
     )

关于python - 打印函数反斜杠消失Python 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32238153/

相关文章:

python - 我可以使用 Pygame 为单个事件同时按下两个键吗?

sql - 如何在 SQL 中打印表的结构及其内容

python - 如何使用 Pytest 测试 dockerized Flask 应用程序?

python - 使用 Python 从安全网站中提取和解析 HTML?

css - 如何通过 CTRL+p 使用打印机友好功能?

c - C中打印Trie的内容和数量

java - 使用 Java 将 PDF(1.4 和 1.5)可靠地打印到网络打印机

powershell - 使用 Powershell 将文本文件文件夹打印为 PDF(保留原始基本名称)

python - 制作自定义(tf.function)函数二维数组

javascript - SoundCloud API 可以直接从 Windows 访问(例如使用 python 脚本)还是必须是从服务器运行的互联网应用程序?