# 一行Python代码能实现什么奇葩功能？

mandelbrot 图像中文名叫曼德勃罗图像。Mandelbrot 图像中的每个位置都对应于公式 N=x+y*i 中的一个复数。其实数部分是 x，虚数部分是 y，i 是 -1 的平方根。图像中各个位置的 x 和 y 坐标对应于虚数的 x 和 y 部分。百度百科给出的图形是这样的。

```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)]))
```

`print('\n'.join([' '.join(['%s*%s=%-2s' % (y, x, x*y) for y in range(1, x+1)]) for x in range(1, 10)]))`

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

```exec("""\nfrom turtle import *\nfor i in range(500): \n    forward(i)\n    left(91)\n""")
```

`print(' '.join([str(item) for item in filter(lambda x: not [x % i for i in range(2, x) if x % i == 0], range(2, 101))]))`

`print([x[0] for x in [(a[i][0], a.append([a[i][1], a[i][0]+a[i][1]])) for a in ([[1, 1]], ) for i in range(30)]])`

```quickSort = lambda array: array if len(array) <= 1 else quickSort([item for item in array[1:] if item <= array[0]]) + [array[0]] + quickSort([item for item in array[1:] if item > array[0]])
array = [9, 11, 88, 32, 8]
print(quickSort(array))```

```>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!```

```import antigravity
```

cmd 命令下输入下列代码实现单线迷宫。

`python -c "while 1:import random;print(random.choice('|| __'), end='')"`

```python -m http.server 8080
```

```python -c "import random;p=lambda:random.choice('7♪♫♣♠♦♥◄☼☽');[print('|'.join([p(),p(),p()]),end='\r') for i in range(8**5)]”
```

```[__import__('sys').stdout.write('\n'.join('.' * i + 'Q' + '.' * (8-i-1) for i in vec) + "\n========\n") for vec in __import__('itertools').permutations(range(8)) if 8 == len(set(vec[i]+i for i in range(8))) == len(set(vec[i]-i for i in range(8)))]
```

```print([i for item in ab for i in item])
```

```ab = [[1, 2, 3], [5, 8], [7, 8, 9]]
print([i for item in ab for i in item])

# 结果
[1, 2, 3, 5, 8, 7, 8, 9]```

2 的 1000 次方的值很大，把结果每位数都加起来等于多少呢？

```print(sum(map(int, str(2**1000))))

# 结果
1366```

`print("I Love You!\n" * 3000)`

0 条评论

• ### 【Python 第25课】 初探list

昨天课程里的例子有点没说清楚，有同学表示写在程序里发生了错误。因为我当时写这个代码片段时，心里假想着这是在一个函数的内部，所以用了return语句。如果你没有把...

• ### 如何安装 Python 的第三方模块

正所谓“人生苦短，我用 Python”。Python 的一大优势就是有丰富且易用的第三方模块，省去了大量重复造轮子的时间，节约了众多开发者的生命。对于已经熟悉 ...

• ### #PY小贴士# for 循环定义的变量，循环外可以用吗？

我们知道，在 python 中要获取一个变量的值，必须是先给它赋值过，不然就是未定义。那么这个 i，代码中没有显式的赋值，在循环体之外还可以用吗？

• ### [快学Python3]循环控制

概述 本节我们主要介绍Python中的循环控制的使用。 for循环 在Python中for循环可以遍历任何序列，例如元组、列表、字符串、字典、集合等等。 先看下...

• ### 广告小程序后端开发

1.key设置路径：微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置

• ### python 编程实例 1

#题目：有 1、2、3、4 个数字，能组成多少个互不相同且无重复数字的三位数？都是多

Crossin的编程教室创始人