python 库来绘制基本形状?

A python library to draw basic shapes?

我用谷歌搜索了一下,找到的是像 turtle 和 tkinter 这样的库,它们对我想要的东西来说太好了

我想要这样的形状

print(" _______")
print("|1     2|")
print("|       |")
print("|3     4|")
print(" ------- ")

或者像这样

print(" _______")
print("|       |")
print("|       |")
print("|       |")
print(" ------- ")

我们是否有任何库可以制作具有不同形状和大小的形状, 比 turtle 和 matplotlib 更简单的东西。

看看这个图书馆: https://github.com/nschloe/termtables

这会在终端上打印表格。

示例:

    import numpy
    import termtables as tt
    numpy.random.seed(0)
    data = numpy.random.rand(5, 2)

    string = tt.to_string(data)

输出:

┌────────────────────┬────────────────────┐
│ 0.5488135039273248 │ 0.7151893663724195 │
├────────────────────┼────────────────────┤
│ 0.6027633760716439 │ 0.5448831829968969 │
├────────────────────┼────────────────────┤
│ 0.4236547993389047 │ 0.6458941130666561 │
├────────────────────┼────────────────────┤
│ 0.4375872112626925 │ 0.8917730007820798 │
├────────────────────┼────────────────────┤
│ 0.9636627605010293 │ 0.3834415188257777 │
└────────────────────┴────────────────────┘

另一种选择是:

https://github.com/zvibazak/termshape

示例:

打印一个正方形:

from tremshape import get_square
print(get_square(5))
* * * * *
*       *
*       *
*       *
* * * * *