|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
为了实验Python 包,设置了D:\Programs\test 目录。并且创建了一个__init__文件。在这个目录下加入了一个模块p1.py,
#p1.py
def c2f(cel):
fah = cel *1.8+32
return fah
def f2c(fah):
cel = (fah-32)/1.8
return cel
用sys.path.append('D:\\Programs\\test') 增加目录
['C:\\Users\\Administrator\\Desktop', 'D:\\Programs\\Python\\Python36\\python36.zip', 'D:\\Programs\\Python\\Python36\\DLLs', 'D:\\Programs\\Python\\Python36\\lib', 'D:\\Programs\\Python\\Python36', 'D:\\Programs\\Python\\Python36\\lib\\site-packages', 'C:\\Users\\Administrator\\Desktop', 'D:\\Programs\\test', 'D:\\Programs']
#调用这个模块,
import test.p1 as tc
结果出现错误:
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
import test.p1 as tc
ModuleNotFoundError: No module named 'test.p1'
科尔沃 发表于 2017-11-22 22:31
我也增加了 这个目录,D:\\Programs,但还是报错
我估计可能是你的默认路径下也有个叫做test的包,而里面没有p1.py这个文件
|
|