ASCII文本在Python中未居中。

huangapple go评论72阅读模式
英文:

ASCII Text not centering in Python

问题

我得到了一些ASCII文本,但它没有居中,为什么?:

pray=text2art("Pray")
new_pray = pray.center(90)

@bot.event
async def on_ready():
    print(f"""{Fore.YELLOW}{new_pray}""")

只有当它不是ASCII样式文本时才有效。

英文:

I got some ascii text but it's not centering, why?:

pray=text2art("Pray")
new_pray = pray.center(90)

@bot.event
async def on_ready():
    print(f"""{Fore.YELLOW}{new_pray}""")

It only works if it's not ASCII style text.

答案1

得分: 1

center函数将单个字符串对齐到提供的空间。text2art将一行转换为多行。center不处理多行。首先进行居中对齐,然后调用text2art

英文:

The center function aligns a single string in the space provided. text2art converts one line to multiple lines. center doesn't handle multiple lines. Do the centering first, THEN call text2art.

huangapple
  • 本文由 发表于 2023年6月26日 07:04:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552727.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定