租用问题

质量为本、客户为根、勇于拼搏、务实创新

< 返回租用问题列表

python怎么输出带框文字,python怎么输出pi

发布时间:2024-06-12 17:34:04

python怎样输出带框文字

要在Python中输出带框文字,你可使用以下代码:

def print_box_text(text):
    length = len(text) + 4
    print("*" * length)
    print("* " + text + " *")
    print("*" * length)

text = "Hello, this is a box text!"
print_box_text(text)

运行以上代码,将输出以下内容:

*******************************
* Hello, this is a box text! *
*******************************