python 用于在python中绘制的不同字符串形状
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 用于在python中绘制的不同字符串形状相关的知识,希望对你有一定的参考价值。
def strsquare(char, wid):
row = ''.join([char for elem in range(wid)]) + '\n'
shape = ''.join([row for elem in range(wid)])
return shape
def printsquare(char, wid):
print(strsquare(char, wid))
def strtriangle(char, wid):
shape = ''
count = 0
while count < wid:
shape += ''.join([char for elem in range(count)]) + '\n'
count += 1
return shape
def downwardtriangle(char, wid):
shape = ''
count = wid
while count > 0:
shape += ''.join([char for elem in range(count)]) + '\n'
count -= 1
return shape
以上是关于python 用于在python中绘制的不同字符串形状的主要内容,如果未能解决你的问题,请参考以下文章