
使用字符串方法
str.rjust:
>>> num = int(input("Enter the number of rows: "))>>> for i in range(1, num + 1):... print(" ".join("*" * i).rjust(num * 2))Enter the number of rows: 5 * * * * * * * * * * * * * * *欢迎分享,转载请注明来源:内存溢出

使用字符串方法
str.rjust:
>>> num = int(input("Enter the number of rows: "))>>> for i in range(1, num + 1):... print(" ".join("*" * i).rjust(num * 2))Enter the number of rows: 5 * * * * * * * * * * * * * * *欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)