【python文化-小彩蛋】

Python 一些有趣的彩蛋,你都知道吗?

python作为一门开源的语言,它的社区为其贡献了一些十分幽默的东西

1.__hello__

在大多数情况下,我们每次学习一门语言时,第一个都会将将“Hello World”打印到屏幕。这可能是在学习新的编程语言时首先要做的。为此在python幽默的文化里,就提供了一个魔法模块__hello__,就可以做到打印"hello world"

>>> import __hello__
      Hello world!

2.经典的Python之蝉

>>> 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.
Readability counts.
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!

参考翻译:
优美胜于丑陋。 显式胜于隐式。 简单胜于复杂。 复杂胜于难懂。 扁平胜于嵌套。 分散胜于密集。 可读性应当被重视。 尽管实用性会打败纯粹性,特例也不能凌驾于规则之上。 除非明确地使其沉默,错误永远不应该默默地溜走。 面对不明确的定义,拒绝猜测的诱惑。 用一种方法,最好只有一种方法来做一件事。 虽然一开始这种方法并不是显而易见的,但谁叫你不是 Python 之父呢。 做比不做好,但立马去做有时还不如不做。 如果实现很难说明,那它是个坏想法。 如果实现容易解释,那它有可能是个好想法。 命名空间是个绝妙的想法,让我们多多地使用它们吧!

3.“反重力”漫画

>>> import antigravity #将会跳到一个网页

输入这行代码,会直接跳转到漫画网页 xkcd。
在这里插入图片描述
“你在飞!怎么做到的?”
“Python!”
“我昨晚学习了 Python,一切都是那么简单”
“运行 HELLO WORLD 只需要 print “Hello World!””
“我还是不明白……动态类型,还是空格?”
“来加入我们吧,编程又再次变得有趣起来了,Python 是一个全新的世界”
“但你是怎么飞起来的?”
“我只是输入了 import antigravity”
“就这样?”
“我还对药品柜中的所有东西进行了采样比较”(暗指他对比过多种编程语言,但还是觉得 Python 最简单)
“但我想这就是 Python.”

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

骑着蜗牛追汤圆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值