Catalog
  1. 1. 1.一行代码打印乘法口诀
  2. 2. 2.一行代码打印迷宫
  3. 3. 3.一行代码(土味)表白
  4. 4. 4.一行代码打印龟龟(/滑稽)
一行 Python 代码能实现什么丧心病狂的功能?

1.一行代码打印乘法口诀

1
print('\n'.join([' '.join(["%2s x%2s = %2s"%(j,i,i*j) for j in range(1,i+1)]) for i in range(1,10)]))

20190719141327674

2.一行代码打印迷宫

1
print(''.join(__import__('random').choice('\u2571\u2572') for i in range(50*24)))

20190719104644249

3.一行代码(土味)表白

1
print('\n'.join([''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0else' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))

20190719104826750

4.一行代码打印龟龟(/滑稽)

1
print('\n'.join([''.join(['*' if abs((lambda a:lambda z,c,n:a(a,z,c,n))(lambda s,z,c,n:z if n==0 else s(s,z*z+c,c,n-1))(0,0.02*x+0.05j*y,40))<2 else ' ' for x in range(-80,20)]) for y in range(-20,20)]))

20190719105008201

Author: Christopher Shen
Link: https://www.pasxsenger.com/2019/11/04/一行-Python-代码能实现什么丧心病狂的功能?/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Donate
  • 微信
  • 支付寶