小编Tra*_*son的帖子

为什么Python 2允许列表和数字之间的比较?

我最近在我的程序中发现了一个拼写错误

while len(first_list) > second_list:
    do_stuff
Run Code Online (Sandbox Code Playgroud)

我打得四处这一点,并发现5 < ["apple"] == True5 > ["apple"] == False

为什么Python允许这些类型的比较?什么是在引擎盖下评估,以确定5是否小于["apple"]

python python-2.7

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

不允许美元符号代替括号

替换此函数中的括号:

isInteger x = x == fromInteger (round x)
Run Code Online (Sandbox Code Playgroud)

与美元符号运算符:

isInteger x = x == fromInteger $ round x
Run Code Online (Sandbox Code Playgroud)

引发错误.

使用$运算符有什么限制?

haskell

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

标签 统计

haskell ×1

python ×1

python-2.7 ×1