简体   繁体   English

除了为模块分配功能之外,有什么办法吗?

[英]Is there any way rather than assigning functions to modules?

I found this definition of modules in Python:我在 Python 中找到了这个模块的定义:

"Structures that contain functions or properties, in which we can declare variables." “包含函数或属性的结构,我们可以在其中声明变量。”

Don't we need to assign functions to modules every time, or is there any way rather than assigning functions?我们不是每次都需要为模块分配功能,还是有什么办法可以不用分配功能?

Per the Python docs I think we can update the definition just a little: A module is a file containing Python definitions and statements根据 Python 文档,我认为我们可以稍微更新一下定义:模块是包含 Python 定义和语句的文件

So you don't really need to have a function in a module if you don't want :)因此,如果您不想要,您实际上并不需要在模块中具有功能:)

Reference: https://docs.python.org/3/tutorial/modules.html参考: https ://docs.python.org/3/tutorial/modules.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有什么方法可以查看Python 3模块中的源函数吗? - Is there any way to see source functions in Python 3 Modules? 有没有办法返回 add、sub、mul 函数的点而不是字符串? - is there a way to return the points for the add,sub,mul functions rather than the string? 有什么方法可以使用ConfigParser评估公式而不是对字符串进行插值吗? - Is there any way to use ConfigParser to evaluate formulas rather than interpolate strings? Python 漂白剂:有没有办法去除不允许而不是允许的标签? - Python Bleach: is there any way to strip tags that are disallowed rather than allowed? 有没有办法在多个值上运行np.where而不是一个? - Is there any way to run np.where on multiple values rather than just one? 有没有办法在Java中而不是整个类中获取代码块的AST(抽象语法树)? - Is there any way to get the AST (Abstract Syntax Tree) of a block of code in Java rather than of the entire class ? 有没有其他方法可以从动态网站中提取数据,而不是使用 selenium? - Is there any other way to extract data from dynamic website, rather than using selenium? 有没有办法在 tkinter window 中显示文件浏览器而不是打开文件对话框? - Is there any way to show the file browser INSIDE a tkinter window rather than an open file dialogue? 有没有什么简单的方法可以根据他们的 position 而不是 kwargs 通过 arguments。 像 kwargs 的位置版本? - Is there any simple way to pass arguments based on their position, rather than kwargs. Like a positional version of kwargs? (discord.py) on_message 事件有什么办法可以查看嵌入的而不是普通的消息吗? - (discord.py) Is there any way for the on_message event to look into an embedded rather than a normal message?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM