def parse_buckets(xml): root = ET.fromstring(xml) buckets = root.find('{0}Buckets'.format(ListAllMyBuckets.NS)).findall('{0}Bucket'.format(ListAllMyBuckets.NS)) entries = [] for bucket in buckets: name = bucket.find("{0}Name".format(ListAllMyBuckets.NS)).text #获取bucket的名称 d = bucket.find("{0}CreationDate".format(ListAllMyBuckets.NS)).text #获取bucket的创建日期 creation_date = Utils.transfer_date(d) #将创建日期转换为当地时间 curr_bucket = Bucket(name, creation_date) #创建bucket对象 entries.append(curr_bucket) #向entries列表中添加bucket对象 return entries