且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python中的Ascii艺术不在一行中打印

更新时间:2023-11-22 13:51:04

print() in Python 3 prints newlines unless you tell it not to. Pass in end='' to tell it not to print that newline:

def row_top():
    print("|--|--|--|--|--|--|--|--|")

def cell_left():
     print("| ", end='')

def cell_data(isQ):
     if isQ:
        print("X", end='')
    else:
        print(" ", end='')

def row(c):
    row_top()
    row_data(c)
    print("|")