要在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)
運(yùn)行以上代碼,將輸出以下內(nèi)容:
*******************************
* Hello, this is a box text! *
*******************************