首页 > 技术文章 > def函数安装调用的疑惑

xflqm 2017-08-26 15:49 原文

如果在新建File中定义了def,F5在shell中运行成功,那么在同一个shell中可以调用这新定义的函数。

但是如果关闭了shell新打开一个shell,那么调用不成功。

>>> import nester3
>>> sarah = nester3.get_coach_data('sarah.txt')
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    sarah = nester3.get_coach_data('sarah.txt')
AttributeError: module 'nester3' has no attribute 'get_coach_data'
>>> 

即使安装这个函数也调用不成功。不知道为什么。

推荐阅读