Skip to main content
 首页 » 编程设计

Python 并且不是 None

2025年05月04日10xxx_UU

<分区>

我在处理这段代码时遇到了一些问题:

if not fundbenchmark.endswith(("Index", "INDEX")) and fundbenchmark is not None: 
    fundbenchmark = "%s%s" % (fundbenchmark, " Index") 

回溯:

AttributeError: 'NoneType' object has no attribute 'endswith' 

显然当 fundbenchmark 为 None 时会出现此错误。暗示有问题,fundbenchmark不是None:

我的这个假设是否正确,还是可以在其他地方找到解释?