[python]Python 中 if not 用法
在python 判断语句中 None, False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()都相当于 False
not None == not False == not '' == not 0 == not [] == not {} == not ()
需要注意的是'0'这个进行判断返回的是true
def test(val):
if not val:
print 'not'
else:
print 'yes' test(0)
test(None) test('') if not 0:
print 1111
返回
not
not
yes
[python]Python 中 if not 用法的更多相关文章
- Python numpy中矩阵的用法总结
关于Python Numpy库基础知识请参考博文:https://www.cnblogs.com/wj-1314/p/9722794.html Python矩阵的基本用法 mat()函数将目标数据的类 ...
- python代码中pass的用法
我们有时会在方法中写一些注释代码,用来提示这个方法是干嘛的之类,看下面代码: class Game_object: def __init__(self, name): self.name = name ...
- python pandas 中 loc & iloc 用法区别
转自:https://blog.csdn.net/qq_21840201/article/details/80725433 ### 随机生DataFrame 类型数据import pandas as ...
- Python ctypes中cast/py_object用法
class ctypes.py_object Represents the C PyObject * datatype. Calling this without an argument create ...
- python xpath 中的全部用法
不好意思 ,太仓促只能给你们个url 链接:https://blog.csdn.net/hhtnan/article/details/77509549
- python scapy中sniffer的用法以及过滤器
Sniff方法定义: sniff(filter="",iface="any", prn=function, count=N) 1.filter的规则使用 Ber ...
- python 中del 的用法
python中的del用法比较特殊,新手学习往往产生误解,弄清del的用法,可以帮助深入理解python的内存方面的问题. python的del不同于C的free和C++的delete. 由于pyth ...
- Python中AND-OR的用法
学习Python中的lambda函数的时候,才发现原来Python中的AND和OR还可以有一些别的用法.Python中的布尔逻辑计算的结果并非返回布尔值,而是返回它们相互之间的某一个.文章的部分例子来 ...
- python中argparse模块用法实例详解
python中argparse模块用法实例详解 这篇文章主要介绍了python中argparse模块用法,以实例形式较为详细的分析了argparse模块解析命令行参数的使用技巧,需要的朋友可以参考下 ...
- Python面向对象中super用法与MRO机制
1. 引言 最近在研究django rest_framework的源码,老是遇到super,搞得一团蒙,多番查看各路大神博客,总算明白了一点,今天做一点总结. 2. 为什么要用super 1)让代码维 ...
随机推荐
- HTML与W3C
HTML:超文本标记语言 超文本包括:文字.图片.音频.视频.动画等 流程:写好HTML代码后通过浏览器(自动编译HTML代码)展现出效果 HTML优点: 世界知名浏览器厂商对HTML5的支持 微软 ...
- laravle中常见的数据库加密
// 1.md5加密 $str=md5('123456'); // 2.base64_decode加密 $str2=base64_encode('123456'); // 2.1 base64_解密 ...
- Linux下安装python,mysql,redis
linux 安装Python3 1.python下载 请在终端输入如下命令: cd /home wget http://cdn.npm.taobao.org/dist/python/3.6.5/Pyt ...
- 2017-9-15Opencv 杂
Mat::at()的具体含义.指的是三通道.(0),(1),(2)分别表示BGR: Vector<Mat>结构的使用.将Mat类型的数据转化成了具有多个单通道的容器? 灰度图的具体含义.和 ...
- npm vs yarn
npm yarn npm install yarn npm install react --save yarn add react npm uninstall react --save yarn re ...
- Server2012多用户远程桌面及问题解决记录
1.开启远程桌面 转载自 https://jingyan.baidu.com/article/c275f6ba9321fda33c756712.html 2.添加用户 转载自 https://jin ...
- 多模块打war包
1.在启动类的那个模块中的pom.xml中加入<packaging>war</packaging> 就这句 <groupId>com.mybatis</gr ...
- H5手机端开发问题及解决方案
ios竖屏拍照上传,图片被旋转问题 1.通过第三方插件exif-js获取到图片的方向2.new一个FileReader对象,加载读取上传的图片3.在fileReader的onload函数中,得到的图片 ...
- Python中pip的使用
1.pip安装模块 pip install 模块名称 -i 安装源 pip install requests -i https://mirrors.aliyun.com/pypi/simple/
- Date/Math/String对象的函数
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...