def tempr():
print("in the function")
.
.
.
.
tempr()
python函数就是这样工作的,而
tempr()
.
.
.
.
.
def tempr():
print("in the function")
这行不通
while in c++ we have a prototype declaration to tell the compiler that the function exists. what do I do here? Can Python handle such kind of c++ kind of function call statement above the function definition
简单的回答是:您必须在代码中遵循
top-down
结构,这是一个很好的实践。设置它的方式基本上导致调用undefined
函数,因为它甚至没有在内存堆栈中设置(在运行时)在调用函数之前定义或导入该函数。这是没有办法的
不,Python目前没有函数原型。正如Iain Shelvington所说,函数和变量都是对象。(从字面上说,Python中的一切都是对象)因为在使用之前必须定义一个变量,与函数相同。如果不想看到,可以将函数放入另一个文件并导入
相关问题 更多 >
编程相关推荐