首页 > 解决方案 > Python无法解析变量,鸭子打字说?

问题描述

我已将我的变量定义如下;

timestamp_set = set([])

def doUpdate():

    if len(timestamp_set) == 0:
        tset = get3daysoffset()
        timestamp_set = tset <---If this line removed no error warnings

在上面的代码块中,它说 if 条件中的 timestamp_set 变量无法解析;

Unresolved reference 'timestamp_set' less... (⌘F1) 
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items

如果我删除timestamp_set = tset行,pycharm 没有显示任何错误警告。这里有什么问题?

标签: python

解决方案


推荐阅读