Is it possible only to declare a variable without assigning any value in Python?

后端 未结 14 1854
暖寄归人
暖寄归人 2020-11-30 17:26

Is it possible to declare a variable in Python, like so?:

var

so that it initialized to None? It seems like Python allows this, but as soon

14条回答
  •  隐瞒了意图╮
    2020-11-30 17:51

    Is it possible to declare a variable in Python (var=None):

    def decl_var(var=None):
    if var is None:
        var = []
    var.append(1)
    return var
    

提交回复
热议问题