[英]importing a module file into python
I am beginning to learn python. 我开始学习python。 I wrote the following module file to be imported into python, but the output in IDLE does not show anything. 我编写了以下要导入到python中的模块文件,但是IDLE中的输出未显示任何内容。 Please help 请帮忙
def main():
print("This program illustrates a chaotic function")
x=eval(input("enter a number between 0 and 1:"))
for i in range(10):
x=3.9*x*(1-x)
print(x)
main()
I used import chaos
command to import the module, but it doesn't show any output. 我使用import chaos
命令导入模块,但未显示任何输出。
-------chaos.py---------- ------- chaos.py ----------
def main():
print("This program illustrates a chaotic function")
x=eval(input("enter a number between 0 and 1:"))
for i in range(10):
x=3.9*x*(1-x)
print(x)
-------fileimport.py--------- ------- fileimport.py ---------
import chaos
chaos.main()
Note Both these files should be in same directory 注意这两个文件应该在同一目录中
Parent Folder
|
|----chaos.py
|----fileimport.py
Main.py 主程序
import chaos
print(chaos.hello())
chaos.py chaos.py
def hello():
return "hello"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.