相关疑难解决方法(0)

Python:从空列表中弹出

我在代码中的循环中使用下面的行

importer = exporterslist.pop(0)
Run Code Online (Sandbox Code Playgroud)

如果exporterslist没有条目,或者它是null,则返回error: IndexError: pop from empty list.如何在没有条目的情况下绕过exporterslist?

我能想到的一个想法是,如果exporterslist不为null,则importer = exporterslist.pop(0) 获取循环中的下一个条目.如果想法是正确的,如何在python中编码?

python python-2.7

9
推荐指数
3
解决办法
3万
查看次数

标签 统计

python ×1

python-2.7 ×1