初学python,模块导入遇到有关问题,求解 返回列表 发新帖回复

初学python,模块导入遇到问题,求解 返回列表 发新帖回复
最近在看《python基础教程》,学到第十章模块那儿了,但是我照着书上的程序打上去怎么不对呢?
我先在电脑F盘python文件夹下建立了个test.py的文件
代码如下:

    def hello():
        print 'hello'


复制代码


然后在python IDLE里面想引用这个模块的hello函数
如下

    >>> import sys
    >>> sys.path.append("F:\python")
    >>> import test
    >>> test.hello()


复制代码


结果就报错,显示如下内容:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    test.hello()
AttributeError: 'module' object has no attribute 'hello'


请问下这是怎么回事啊?我是按照书上的步骤来的啊,代码就是照着书上打上去的,怎么会这样?

PS:这个语言的语法好灵活,反而好不习惯
------解决方案--------------------
引用:
test是个标准模块吧 即使你不append也可以直接导入的



这个应该是正确的,如果找不到test.py文件则在import test的时候就会报错