Python中的None与 NULL(即空字符)的区别
None是Python的特殊类型,NoneType对象,它只有一个值None.
它不支持任何运算也没有任何内建方法。
None和任何其他的数据类型比较永远返回False。
None有自己的数据类型NoneType。
可以将None复制给任何变量,但是不能创建其他NoneType对象。
是一种数据类型:
>>>type(None)
<class 'NoneType'>
表示该值是一个空对象,空值是Python里一个特殊的值,用None表示。None不能理解为0,因为0是有意义的,而None是一个特殊的空值。
>>>type('')
<class ''str'>
可以将空值赋值给任何变量,可以将任何变量赋值给一个空值的对象
判断的时候 均是False
>>> ff = None
>>> if ff:
print('ff is define')
执行结果:无打印!
属性不同
使用dir()函数返回参数的属性、方法列表。如果参数包含方法dir(),该方法将被调用。如果参数不包含dir(),该方法将最大限度地收集参数信息。
>>> dir(None)
['__bool__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] >>> dir('')
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
Python中的None与 NULL(即空字符)的区别的更多相关文章
- PythonStudy——Python中的None与 NULL(即空字符)的区别
None与 NULL(即空字符)的区别 (1)是不同的一种数据类型 >>>type(None) <class 'NoneType'> >>>type( ...
- Python中的None与Null(空字符)的区别
参考自 Python中的None与空字符(NULL)的区别 - CSDN博客 http://blog.csdn.net/crisschan/article/details/70312764 首先了解p ...
- python中urllib, urllib2,urllib3, httplib,httplib2, request的区别
permike原文python中urllib, urllib2,urllib3, httplib,httplib2, request的区别 若只使用python3.X, 下面可以不看了, 记住有个ur ...
- python中生成器对象和return 还有循环的区别
python中生成器对象和return 还有循环的区别 在python中存在这么一个关键字yield,这个关键字在项目中经常被用到,比如我写一个函数不想它只返回一次就结束那我们就不能用return,因 ...
- Python中%r和%s的详解及区别_python_脚本之家
Python中%r和%s的详解及区别_python_脚本之家 https://www.jb51.net/article/108589.htm
- python中os.path.abspath与os.path.realpath 区别
python中os.path.abspath与os.path.realpath 区别cd /homemkdir amkdir btouch a/1.txtln -s /home/a/1.txt /ho ...
- python 中的input()和raw_input()功能与使用区别
在python中raw_input()和input()都是提示并获取用户输入的函数,然后将用户的输入数据存入变量中.但二者在处理返回数据类型上有差别. input()函数是raw_intput()和e ...
- python中List append()、extend()和insert()的区别
Python中向列表增加更多数据时,有append().extend()和insert()等方法 其中最常用的是list.append(obj) 向列表的尾部添加一个新的元素. 需要一次性添加多个元素 ...
- 【Python深入】Python中继承object和不继承object的区别
python中定义class的时候,有object和没有object的不同?例如: class Solution(object): class Solution(): 这俩的区别在于—————— 在p ...
随机推荐
- DPDK内存管理-----rte_mbuf(转)
本文主要介绍rte_mbuf与rte_mempool数据结构之间的组织关系.以及网卡接收到的数据是如何存储在rte_mbuf中的. 一.rte_mbuf.rte_mempool及网卡收到的数据包在内存 ...
- Android 之 信息通知栏消息Notification
Notification是安卓手机顶部的消息提示 这里我们分别设置两个按钮,来实现顶部消息的发送和取消 功能实现 首先要在主Activity中设置一个通知控制类 NotificationManager ...
- 22、linux的ssh互信配置
转载:https://blog.csdn.net/hrn1216/article/details/51568830 https://blog.csdn.net/u013144287/article/d ...
- 547D Mike and Fish
传送门 分析 见正睿10.3笔记 代码 #include<iostream> #include<cstdio> #include<cstring> #include ...
- Excel打开图片
=HYPERLINK("D:\固定资产图片\"&C2&".jpg",C2)
- mingw和libcurl
想用curl来做rest的客户端.所以就研究下这方面东西. 1:安装mingw 为什么用mingw,小巧,必vs快,gcc了解的多一些, http://tdm-gcc.tdragon.net/down ...
- Djianggo 在windows中安装出现报错的解决方案
Djianggo 在win7下 安装会报错 Traceback (most recent call last):File "setup.py", line 4, in <mo ...
- 完整读写txt 并提取{}里的内容
using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Lin ...
- C# 快速排序--二分查找法--拉格朗日插值法
1.快速排序 参考自: https://www.cnblogs.com/yundan/p/4022056.html namespace 快速排序算法 { class Program { static ...
- Data Base 常用数据库参数的前缀表示符合
可能参数化SQL语句不同,例如在Access中参数化SQL语句是在参数直接以“?”作为参数名,在SQL Server中是参数有“@”前缀,在MySQL中是参数有“?”前缀,在Oracle中参数以“:” ...