要在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! *
*******************************