【发布时间】:2017-03-05 08:08:45
【问题描述】:
我是 python 新手,正在使用 Learn Python the Hard Way 一书。书中的练习 25 要求我们将 python 模块导入 python 解释器。
我使用“/usr/bin/python”来调用解释器:
S-MacBook-Air:~ s$ /usr/bin/python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
但导入文件时出现错误:
>import ex26_test
>>Traceback (most recent call last):
>>File "< stdin >", line 1, in < module >
>ImportError: No module named ex26_test
文件位于以下文件夹中 (~/documents/1Webdev/LPTHW/ex26_test.py)
请问如何将模块“ex26_test”导入解释器?
提前谢谢你! 标清
【问题讨论】:
-
我看不出你的语法有问题,只要确保你的 PYTHONPATH 全局变量有这个模块的路径
标签: python-2.7