python null None

  python中不能给变量赋null值

>>> a=null
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'null' is not defined

  null=空字符串,class类型为str

>>> a=''
>>> print(type(a))
<class 'str'>

  None的类型为NoneType

>>> a=None
>>> print(type(a))
<class 'NoneType'>

  python的空字符串和None判断时都是false。

  而Javascript中,一个空字符串或空数组的布尔值是true,所以判断是否空数组要用数组的length属性

猜你喜欢

转载自www.cnblogs.com/luozx207/p/9964766.html