header定义的内容:

Python3-接口自动化-12- header定义为字典格式,但是报错:for header in headers.items(): AttributeError: 'tuple' object has no attribute 'items'

 

 返回类型为:字典

在程序中读取header后,类型变成了tuple:

Python3-接口自动化-12- header定义为字典格式,但是报错:for header in headers.items(): AttributeError: 'tuple' object has no attribute 'items'

 

 

 

 

 所以会报错:

Python3-接口自动化-12- header定义为字典格式,但是报错:for header in headers.items(): AttributeError: 'tuple' object has no attribute 'items'

 

分析:

header返回类型没有问题 

仔细检查发现:

Python3-接口自动化-12- header定义为字典格式,但是报错:for header in headers.items(): AttributeError: 'tuple' object has no attribute 'items'

 

 因为无中生有多了两个逗号,所以dict被转成了tuple

去掉即可

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-01-07
  • 2021-09-02
  • 2022-12-23
猜你喜欢
  • 2021-11-03
  • 2021-12-07
  • 2022-02-13
  • 2022-02-26
  • 2022-12-23
  • 2021-04-18
  • 2022-12-23
相关资源
相似解决方案