小编del*_*eet的帖子

Python 的 not() 函数不是普通函数?

所以我知道 python 有 not 运算符,但是 not() 函数是如何发挥作用的?

从一些简单的测试来看,它似乎具有 not(args[]) 的签名,同时又不完全像一个普通函数。例如:

x = True
not x # -> False
not(x) # -> False
x = False
not x # -> True
not(x) # -> True

not(0) # -> True
not(1) # -> False
not(0, 0, 0) # -> False
not("False") # -> False

function = not # -> Syntax Error
Run Code Online (Sandbox Code Playgroud)

为什么这存在于“不是”,而不是像“或”这样的东西?有没有办法可以将 not 函数捕获到变量中/不作为函数进行其他操作?

这个问题主要是因为试图找到一个函数来反转 map 调用中的列表,即使它是一个内部函数

python python-3.x

1
推荐指数
1
解决办法
499
查看次数

标签 统计

python ×1

python-3.x ×1