PythonStudy——Python中的None与 NULL(即空字符)的区别
None与 NULL(即空字符)的区别
>>>type(None)
<class 'NoneType'>
>>>type('')
<class ''str'>
在这里,''代表的是NULL
None表示该值是一个空对象,空值是Python里一个特殊的值,用None表示。None不能理解为0,因为0是有意义的,而None是一个特殊的空值
你可以将None赋值给任何变量,也可以将任何变量赋值给一个None值得对象
(2)判断的时候 均是False
>>> ff=None
>>> if ff:
print('ff is define') 执行结果:无打印!
(3)属性不同
使用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']
PythonStudy——Python中的None与 NULL(即空字符)的区别的更多相关文章
- Python中的None与 NULL(即空字符)的区别
None是Python的特殊类型,NoneType对象,它只有一个值None. 它不支持任何运算也没有任何内建方法. None和任何其他的数据类型比较永远返回False. None有自己的数据类型No ...
- 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 ...
随机推荐
- ETCD集群安装实验
目录 [1.下载二进制程序] [2.安装etcd集群] [3.查询集群状态] [4.存入读取数据] [5.注意事项] [6.参考链接] 简介: Etcd的官网文档及其在GitHub上的文档,已 ...
- Unity---判断某个点是否在摄像机的视景范围内
using UnityEngine; [RequireComponent(typeof(Camera))] public class VisualDetectionCamera : MonoBehav ...
- nova相关操作的Request_Id的获取
在分析nova的众多log文件时,如nova-api,nova-scheduler,nova-compute等,其中的request id是串联起整个flow的关键词. 而通过nova instanc ...
- jTimer
很多时候我们需要按时间间隔执行一个任务,当满足一定条件时停止执行.此插件旨在解决这一经常遇到的问题. jTimer: (function ($) { $.extend({ timer: funct ...
- yii2解决资源插件路径不对应问题
//本人ubuntu系统 composer self-update //升级到最新 //官网找到最新下面的这行执行. composer global require "fxp/compose ...
- [la P5031&hdu P3726] Graph and Queries
[la P5031&hdu P3726] Graph and Queries Time Limit: 10000/5000 MS (Java/Others) Memory Limit: ...
- Netflix:我们为什么要将 GraphQL 引入前端架构? (转)
在刚开始时,Monet 的 React UI 层需要访问由 Tomcat 服务器提供的传统 REST API.随着时间的推移,随着应用程序的发展,我们的用例变得越来越复杂,即使是一个简单页面也需要从各 ...
- Python *Mix_w5
1. 字典dict dict 用{}来表示 ,键值对数据{key:value} key具有唯一性 键:都必须是可哈希的,除了列表,不可变的数据类型都可以当做字典中的键 值 没有任何限制 2. 字 ...
- python魔术方法(__init__,__call__,被双下划线包围的方法)
转载link:http://pycoders-weekly-chinese.readthedocs.io/en/latest/issue6/a-guide-to-pythons-magic-metho ...
- linux基本网络配置
-- linux基本网络配置管理 rhel6开始有一个networkmanger的网络配置服务(可以图形配置网络,拔号,无线连接,vpn等)但此服务开启会造成你的ip不固定(会dhcp获取),而且后期 ...