python - 调试时如何查看for循环中每个迭代/步骤的输出
问题描述
我有一个嵌套的 for 循环,我需要在每次迭代中查看输出以进行调试。我怎样才能做到这一点?
这是我需要查看输出的示例代码。
for sheet_name, df in Input_Data.items():
for line in df:
if line.startswith('Linear'):
index = line.index('Linear')
break
解决方案
尝试这个:
for sheet_name, df in Input_Data.items():
for line in df:
print(line) # just print the line
if line.startswith('Linear'):
index = line.index('Linear')
break
推荐阅读
- blockchain - Pact ToDo MVC - 浏览器中没有处理程序接受“/”消息
- count - uniquerValues - 从 layerView" 和 feature-layer-adapter:insufficient-data 查询统计信息需要视图
- fortran - 在声明的类型中分配参数声明的类型时,ifort 的灾难性错误
- ruby-on-rails - Rails:如何查看 request.referrer 是 GET 还是 POST?
- reactjs - 在反应中从模态中的表单创建新对象
- .net - dotnet 测试:如何将程序集名称包含到 .trx 结果文件中?
- python - 在 Spyder、Python 中导入 numpy 包
- haskell - 为什么我在使用 sinkVector 和 runConduit 时会得到一个非向量类型?
- android-studio - 如果在 Android Studio 中不叫 MainActivity,我怎么知道哪个是 MainActivity?
- c++ - 用 0 初始化的 int 向量给出非零值