【问题标题】:What is the most elegant Pythonic way to write an 'if-statement' within a loop?在循环中编写“if 语句”的最优雅的 Pythonic 方式是什么?
【发布时间】:2022-06-17 15:36:13
【问题描述】:

这是我要执行的操作:

        for sample in samples:
            if sample['something'] is None:
                sample['something'] = 'something_else'

我想用更优雅和 Pythonic 的方式来写这个。如果有 Python 方面的专家可以提供帮助,那就太好了。

【问题讨论】:

标签: python loops


猜你喜欢
  • 1970-01-01
  • 2022-10-25
  • 1970-01-01
  • 2018-06-06
  • 1970-01-01
  • 2010-11-22
  • 2011-10-22
  • 1970-01-01
  • 2014-02-03
相关资源
最近更新 更多