Initialize a string variable in Python: “” or None?

前端 未结 11 477
鱼传尺愫
鱼传尺愫 2021-01-30 12:44

Suppose I have a class with a string instance attribute. Should I initialize this attribute with \"\" value or None? Is either

11条回答
  •  长发绾君心
    2021-01-30 12:57

    It depends. If you want to distinguish between no parameter passed in at all, and an empty string passed in, you could use None.

提交回复
热议问题