Sorry basic question I'm sure but I can't seem to figure this out.
Say I have this program , the file is called pythonFunction.py
:
def function():
return 'hello world'
if __name__=='__main__':
print function()
How can I call it in another program?
I tried:
import pythonFunction as pythonFunction
print pythonFunction.function
Instead of 'hello world', I get ...I have done this in the past by making the first file a class, but I was wondering how to import the function correctly? If it helps, in my real file, I am printing a dictionary
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…