我正在使用python3版本关注第一本python书。 我的目录中有我的nester文件夹 C:\ Users \ Nimmi \ AppData \ Local \ Programs \ Python \ Python36 \ Lib \ site-packages \ nester,如我的图片
当我导入模块nester时,IDLE上没有发生错误:
>>import nester
我在我的nester.py中写了以下密码:
def print_lol(the_list,level):
for each_item in the_list:
if isinstance(each_item, list):
print_lol(each_item)
else:
for tab_stop in range(level):
print("\t", end ='')
print(each_item)
当我尝试调用nester.print_lol()函数时,它给出了错误说:
Traceback (most recent call last):
文件"",第1行,in nester.print_lol(casu) AttributeError:module' nester'没有属性' print_lol'
其中casu = ['圣日','生命意义'] 请告诉我们如何解决此错误