gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 04:32:08 28 4
gpt4 key购买 nike

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

__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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com