目的:使用BDD的时候,feture中传过来的预期结果是列表字符串:assert_list  =  "[1,2,3]",我想要的是[1,2,3]

 

处理方法:使用eval()评估函数;评估的意思就意味着,python处理器判断你想要的结果

 

结果:

list_str = '[1,2,3]'

list1 = eval(list_str)

print(list1)
print(type(list1))

print(list_str)
print(type(list_str))


打印结果========================

[1, 2, 3]
<type 'list'>
[1,2,3]      -----其实是字符串。
<type 'str'>

相关文章:

  • 2022-02-28
  • 2022-01-02
  • 2021-11-10
  • 2021-12-20
  • 2021-11-23
  • 2021-10-08
  • 2022-12-23
猜你喜欢
  • 2021-04-03
  • 2022-02-08
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案