首页 > 解决方案 > Gratient 模块如何在同一行打印文本

问题描述

我正在尝试使用 gratient 模块,但我需要帮助

当我设置此代码时:

import gratient

a = gratient.green("[1]")
ab = gratient.red("Private Tool")
print(a, ab)

上面的代码打印文本但在不同的行,我怎样才能在同一行打印它?

标签: python

解决方案


尝试这个:

import gratient

a = gratient.green("[1]")
ab = gratient.red("Private Tool")
print((a + ab).replace("\n", " "))

如果您在 a 或 ab 中有专用的 \n,则此答案无效


推荐阅读