将模块文件导入python

时间:2015-12-17 06:22:26

标签: python

我开始学习python。我编写了以下模块文件以导入到python中,但IDLE中的输出没有显示任何内容。请帮忙

Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'appName' of bean class [java.util.Properties]: Bean property 'appName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
我用过     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() 命令导入模块,但它不显示任何输出。

2 个答案:

答案 0 :(得分:2)

------- 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 ---------

import chaos
chaos.main()

注意这两个文件都应位于同一目录

Parent Folder
          |
          |----chaos.py
          |----fileimport.py

答案 1 :(得分:0)

Main.py

import chaos
print(chaos.hello())

chaos.py

def hello():
   return "hello"