为什么抛出
queue_length = items_in_queue.get_jenkins_queue_len(items_in_queue) AttributeError:'list'对象没有属性'get_jenkins_queue_len'
class JenkinsQueue :
def get_jenkins_items_in_queue(self) :
logger.info("Starting...")
with open('/Users/praveen-bhasker/datafile.json', encoding='utf-8') as data_file:
data = json.loads(data_file.read())
return data["items"]
def get_jenkins_queue_len(self, data):
print(data)
return
jenkinsqueue = JenkinsQueue()
items_in_queue = jenkinsqueue.get_jenkins_items_in_queue()
queue_length = items_in_queue.get_jenkins_queue_len(items_in_queue)
答案 0 :(得分:2)
由于get_jenkins_queue_len()是在JenkinsQueue类中实现的,因此您需要调用该类的对象,因此您必须更换
queue_length = items_in_queue.get_jenkins_queue_len(items_in_queue)
同
jenkinsqueue.get_jenkins_queue_len(items_in_queue)