@classmethod
def _get_header(cls):
_non_validate = ['{\n', '},\n', '}\n}']
_headers = []
with FileManager(cls.file, 'r') as f:
for line in f.readlines():
if not any(_non_validate) in line:
_headers.append(line.split(':')[0].strip('\t"'))
return _headers
有一个功能。我希望它检查字符串中是否至少有一个_non_validate值,如果没有,则将其附加到列表中。如何在语法上正确地将其转换为代码,我的不起作用。
File "/home/artsiom/Desktop/python/JsonPythonConverter/JsonToCsv (1).py", line 115, in _get_header
if not any(_non_validate) in line:
TypeError: 'in <string>' requires string as left operand, not bool
这是错误消息
1 个回答