标签: python
在使用循环之前是否需要检查列表是否为空?
import bpy list = [] if len(list): # is it better to remove this line? for each in list: print(each)
答案 0 :(得分:1)
编写代码以提高可读性和清晰度。除非有理由相信一段代码是代码的瓶颈,否则不要担心优化。我向您保证,清单的长度不是代码中的瓶颈。