开发者

include udf in python?

i've a small user defined function in python, say fib(n), how do i use that in other programs or modules? def fib(n):

should i use import or is there any other feature?

Also i'm learning python in eclipse IDE, it wont support

print "any string"

but i开发者_运维知识库'm forced to use like, print("string")

in python manual online, its given its cross platform and same syntax, but why like above?


You use import to include the function in other programs. Just say import mymodule where the code is located in file mymodule.py. Then say mymodule.fib to use the function.

To answer your second question: The syntax print "any string" is acceptable in Python 2, but is no longer allowed in Python 3.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜