1. 程式人生 > >一句話打印'*'圖案(列表推導式, 人生苦短, 我用Python)

一句話打印'*'圖案(列表推導式, 人生苦短, 我用Python)

`` python inpu for utf-8 一句話 abs 人生苦短 range

```python
# coding=utf-8

print ('\n'.join(['*'*6 for i in range(4)])) 

# ******      
# ******      
# ******      
# ******

print ('\n')
print ('\n'.join(['*'*(i*2+1) for i in range(4)])) 

# *           
# ***         
# *****       
# ******* 

print ('\n') 
print ('\n'.join([('*'*(i*2+1)).center(7, ' ') for i in range(4)])) 

#    *        
#   ***       
#  *****      
# *******

print ('\n') 
print ('\n'.join([('*'*(abs(i-3)*2+1)).center(7, ' ') for i in range(4)]))

# *******     
#  *****      
#   ***       
#    *   

print ('\n') 
print ('\n'.join([('*'*([i,abs(i-6)][i>3]*2+1)).center(7, ' ') for i in range(7)])) 

#    *        
#   ***       
#  *****      
# *******     
#  *****      
#   ***       
#    *   

print ('\n')
print ('\n'.join(['*'*([i,abs(i-6)][i>3]*2+1) for i in range(7)]))

# *           
# ***         
# *****       
# *******     
# *****       
# ***         
# *        

input("nnnnn....")

# nnnnn.... 
```

一句話打印'*'圖案(列表推導式, 人生苦短, 我用Python)