python布尔运算符_Python中布尔的逻辑和按位NOT运算符

本文介绍了Python中的布尔运算符,包括逻辑NOT(not)和按位NOT(~)。逻辑NOT会反转结果,如果原本为True则返回False,反之返回True。按位NOT则是对数字的所有位进行取反操作,返回其补码。文中还提供了这两个运算符的Python程序示例及输出结果。
摘要由CSDN通过智能技术生成

python布尔运算符

In python, not is used for Logical NOT operator, and ~ is used for Bitwise NOT. Here, we will see their usages and implementation in Python.

在python中, not用于逻辑NOT运算符,而〜用于按位NOT。 在这里,我们将看到它们在Python中的用法和实现。

Logical NOT (not) operator is used to reverse the result, it returns "False" if the result is "True"; "True", otherwise.

逻辑NOT(非)运算符用于取反结果,如果结果为“ True”,则返回“ False”。 否则为“ True”。

Bitwise NOT (~) operator is used to invert all the bits i.e. it returns the one's complement of the number.

按位NOT(〜)运算符用于将所有位取反,即它返回一个数字的补码。

Python program of Logical NOT (not) operator

逻辑NOT(非)运算符的Python程序

# Logical NOT (not)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值