0
当卸下空白我有以下代码:使用图示操作者
print(*[((i+1) * '*' + '\n') for i in range(rows)])
产生的输出:
*
**
***
****
*****
所需的输出是:
*
**
***
****
*****
与单个敷贴行,这怎么能做到?我尝试使用.strip(' ')
像这样:
print(*[((i+1) * '*' + '\n').strip(' ') for i in range(rows)])
但它会产生相同的结果。同样的,.replace(' ', '')
比我快。 – chthonicdaemon