Python“测试”模块产生“ TypeError:'模块'对象不可调用”

时间:2019-10-23 17:19:14

标签: python

我尝试了很多次以各种方式使用test模块。我总是收到“ TypeError:'模块'对象不可调用”。这是我从http://openbookproject.net/thinkcs/python/english3e/list_algorithms.html复制粘贴的示例:

import test

def search_linear(xs, target):
  """ Find and return the index of target in sequence xs """
  for (i, v) in enumerate(xs):
    if v == target: return i
  return -1

friends = ["Joe", "Zoe", "Brad", "Angelina", "Zuki", "Thandi", "Paris"]
test(search_linear(friends, "Zoe") == 1)

错误在最后一行产生。

我运行Python 2.7.13。

1 个答案:

答案 0 :(得分:0)

在最后一行应该是test.test(search_linear(friends, "Zoe") == 1)test(test.search_linear(friends, "Zoe") == 1),因为您刚刚导入了测试