当前位置:首页>python>1.1一首藏在Python里的诗

1.1一首藏在Python里的诗

  • 2026-09-07 10:04:36
1.1一首藏在Python里的诗

酥老师说

学编程的第一课,不是背语法,而是让电脑听你的话。这节课,我们只做一件事——让电脑打出一首“诗”。

1.1 一首藏在Python里的诗

你知道吗?Python这门语言里,藏着一首叫做“Python之禅”的诗。它讲的是编程的智慧,写得像禅语,读起来像哲学。

你只需要在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!

酥老师的碎碎念

说句大实话:想学好编程,英语往往是最大的拦路虎。你知道为啥学霸们编程学得快吗?因为他们英语好呀!

英语好的作用可太多啦!

因为英语好,你对单词有着基本的敏感性,import不会敲成inport。

因为英语好,你看得懂报错提示:"NameError: name 'inport' is not defined"。

因为英语好,你知道Now is better than never的意思是“现在做比永远不做强”。

很多“学酥”一看到满屏的英文就想放弃。但老师想告诉你:电脑不看你的英语四六级成绩。我们学编程里的英语,不是为了去考级,而是为了“认路”。所以,咱们每次学编程的时候,顺便把这几个高频词混个脸熟——至少别让它拖你的后腿。

酥老师的通关作业

1、寻找接头暗号:

我不需要你把这19行英文全部翻译出来(那太折磨人了)。请你在上面的诗里,找到那句写给所有“学酥”的话——"Now is better than never"。请把它抄在你的笔记本第一页,或者打在评论区里。这就是我们这门课的接头暗号。只要你打出这句话,就说明你决定不再给自己找借口,你准备好重新出发了。

2、破解魔法咒语:

试着去查一下 import 这个单词的中文意思。在Python里,它就像是一个“召唤术”,你想召唤什么神奇的功能,就用它。查完之后,在心里默念三遍它的拼写。

最新文章

随机文章