gpt4 book ai didi

python - "import this, that, other, stuff"在做什么?

转载 作者:太空狗 更新时间:2023-10-30 01:00:14 30 4
gpt4 key购买 nike

#!/usr/bin/env python
import this, that, other, stuff
class SomeObject(object):
pass

def some_function(*args,**kwargs):
pass

if __name__ == '__main__':
print( "This only executes when %s is executed rather than imported" % __file__)

上面的代码在做什么?我得到如下输出

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 的新手,但非常想知道。请帮帮我。

最佳答案

尝试执行以下操作:

import this

仅这一行就会使解释器输出 Python 之禅

关于python - "import this, that, other, stuff"在做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36570735/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com