name_error: name '没有定义

  • 本文关键字:name 定义 error python
  • 更新时间 :
  • 英文 :


我尝试将final_error_code指定为全局变量,但问题仍然存在。

File "C:Ujjwalsample_python_proj -复制fetch_array.py",第154行,在get_error_code_array .py&quotprint("柠檬挤压", final_error_code)NameError: name 'final_error_code'没有定义


def get_error_code_array():
array_pt_failed_current = []
# global final_error_code
for loop in files:
# print("This is get error code first loop", loop)
with open(loop, 'w+') as file:
# print("This is get error code second loop", loop)
lines = file.readlines()
error_str = json.dumps(lines)
print("This is get error code of ",error_str)
for pt_found in re.finditer('PT-', error_str):
i = pt_found.end() + 1
pt_failed_current = error_str[pt_found.end()] + error_str[i] + error_str[i+1]
array_pt_failed_current.append(pt_failed_current)
final_error_code = ["PT-"+ls for ls in array_pt_failed_current]
# show_error_code_array.append(final_error_code)
print("Lemon Squeeze", final_error_code)
return (final_error_code)

final_error_code在你的循环中被定义。

如果没有定义,这意味着你的循环根本没有循环。

你的for循环条件是:re.finditer('PT-', error_str),所以我假设re.finditer(...)没有发现任何东西。

相关内容

最新更新