点击上方”python宝典”,关注获取python全套视频,
技术文章第一时间送达!
0x00 世界,你好

0x01 Python 哲学

Python 执行 import this 时,会打印出 Python 之禅,就是上面的一段英文,它是 Python 设计和应用的理念。下面是简单的翻译

0x02 Python 还能看漫画

执行上面的命令后,Python 会打开一个神奇的世界

啥,还自带漫画的。下面是从网上找的翻译

0x03 不习惯 Python 的缩进怎么办
我们都知道 Python 的一大特点就是用缩进来管理代码块,而很多语言比如 C/C++ 都是用花括号来管理代码块的。所以 Python 也想到了这一点,试一试这行代码呢。

嘿嘿,你以为这样就可以了。

打脸。这样操作虽说语法是正确的,但你看它报的居然是语法错误。还调皮的说没机会。这…
0x04 关于不等号的选择
本节针对 Python 3 这个版本。
一般编程语言,如 C 、JAVA 等,我们不等号都习惯使用 != 。默认情况下,Python 也是这样的。

但是当我们执行下面这个命令后

结果居然反过来了
这个时候 符号居然正常工作,而 != 却报错了。
原来啊,有一个著名的 Python 开发者,他的外号是叫 FLUFL 。他觉得 ! 和 = 这两个符号在键盘上隔得比较远,而 和 这两个键是挨着的,所以他希望 Python 3 中能支持 的使用,所以就出现了上面的这个情况。
如果你之前学了 C 或者 JAVA 等语言,在看到 Python 的这些操作后,你可能有些措手不及,哈哈。不过,Python 就是这样设计的,它追求的就是有趣以及有个性。
看了之后,是不是想动手试一试呢?赶紧搭上环境玩玩吧。说不定,你还能发现更有趣的东西。
欢迎大家关注,我会带大家发现编程中更多有趣的东西!
原文:https://www.wukong.com/question/6517642623505662221/

识别图中二维码,欢迎关注python宝典