在python脚本中没有得到这样的组错误

2024-09-30 06:29:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python新手,我正在尝试在脚本下面运行。我没有发现这样的IO组错误。我特别提到过,如果那里没有任何物体,就不要进入。在

非常感谢任何帮助。在

错误:

T663xt
count value inside if loop  T663xt
 After appending  ['T663xt']
AB12343
count value inside if loop  AB12343
 After appending  ['T663xt', 'AB12343']
None
None
None
Traceback (most recent call last):
  File "./KPHCcommandGenerator.py", line 55, in <module>
    main()
  File "./KPHCcommandGenerator.py", line 51, in main
    F1.ParsingFile ( InputFile )
  File "./KPHCcommandGenerator.py", line 38, in ParsingFile
    print arrayTemp.group( count )
IndexError: no such group

源代码:

^{pr2}$

正如我们看到的,我正在尝试迭代元组,我得到了形式正则表达式。我可能没有价值观。我只想给我的全局变量添加非None的值。在


Tags: inpynoneloopifvaluecount错误
1条回答
网友
1楼 · 发布于 2024-09-30 06:29:09

首先,如果可能,删除或注释掉这个print语句,因为它在实际工作代码抛出错误之前抛出错误:

print arrayTemp.group( count )

使用try/except块捕获异常,并在超出组范围时妥善处理:

^{pr2}$

相关问题 更多 >

    热门问题