当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | def printStar(intNum):
s = "*"
spaceLength = intNum
blockCount = int(intNum/2+1)
for i in range(spaceLength):
result = s.rjust(blockCount)
if i >= int(spaceLength/2):
print (result)
s = s[2:]
blockCount -= 1
else :
print (result)
s = s+(2* "*" )
blockCount += 1
def oddOReven(intNum):
if intNum%2 == 0:
print ( "please input a odd num data" )
else :
printStar(intNum)
if __name__ == '__main__' :
while True:
try :
intNum = eval (input( "please input a odd num data\n" ))
oddOReven(intNum)
except BaseException as e:
print ( "Please input as 1/2/3... Errorcode:%s" % e)
|
运行结果:

推荐教程:《python视频教程》
以上就是python如何输出星号组成的菱形图形?的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python threading模块中的join()方法
pyquery解析器无法获取标签名dom节点的解决方法
使用Python开发简单的小游戏
Python字符串截取如何操作
学Python拿mac还是windows?
Python中format函数什么意思
unity3d能用Python写吗
Python中strip()函数有什么用法
安装Python后怎么用
Python入门看什么
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python如何输出星号组成的菱形图形?