如果填料测试范围基本 [英] basic if stuff- testing ranges

查看:58
本文介绍了如果填料测试范围基本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sheesh,我一直在努力寻找如何做这个简短的手:

如果0 x< 20:打印在...内


因此x必须为0且< 20.


我通常会这样做:

如果x 0和x< 20:打印内


规则是什么?它甚至存在吗?

我最近在列表上读到了类似的内容但是找不到它,那就是我想要尝试它的冲动从。我在文档中找不到任何东西,但是再次(imho)Python文档就像一个纠结的丛林......

\ d

Sheesh, I''ve been going spare trying to find how to do this short-hand:
if 0 x < 20: print "within"

So that x must be 0 and < 20.

I usually do:
if x 0 and x < 20: print "within"

What''s the rule? Does it even exist?
I read something like it recently on the list but can''t find it, that''s
where I got the urge to try it from. I can''t find anything in the docs, but
then again (imho) the Python docs are like a tangled jungle...
\d

推荐答案

Donn Ingle写道:
Donn Ingle wrote:

Sheesh,我去过备用试图找到如何做这个简短的手:

如果0 x< 20:打印在...内


因此x必须为0且< 20.


我通常会这样做:

如果x 0和x< 20:打印内


规则是什么?它甚至存在吗?
Sheesh, I''ve been going spare trying to find how to do this short-hand:
if 0 x < 20: print "within"

So that x must be 0 and < 20.

I usually do:
if x 0 and x < 20: print "within"

What''s the rule? Does it even exist?



如果0< x< 20:



Mel。

if 0 < x < 20:
?
Mel.


Donn Ingleaécrit:
Donn Ingle a écrit :

Sheesh,我一直在努力寻找如何做这个简短的手:

如果0 x< 20:打印在...内
Sheesh, I''ve been going spare trying to find how to do this short-hand:
if 0 x < 20: print "within"



你的意思是:0< x< 20?


$ x $ bx in xrange(1,20)?

you mean : 0 < x < 20 ?

or

x in xrange(1,20) ?


>

因此x必须为0且< 20.


我通常会这样做:

如果x 0和x< 20:打印内


规则是什么?它甚至存在吗?
>
So that x must be 0 and < 20.

I usually do:
if x 0 and x < 20: print "within"

What''s the rule? Does it even exist?



难以在repl上检查它吗?

is that hard to check it at the repl ?


我最近读了类似的东西列表但是找不到它,那是'b
我从中得到了尝试它的冲动。我在文档中找不到任何东西,但

然后再次(imho)Python文档就像一个纠结的丛林......
I read something like it recently on the list but can''t find it, that''s
where I got the urge to try it from. I can''t find anything in the docs, but
then again (imho) the Python docs are like a tangled jungle...



< what smug,refrained />

<something smug, refrained/>


>


\ n
>

\d


11月26日上午5:49,Donn Ingle< donn.in ... @ gmail.comwrote:
On Nov 26, 5:49 am, Donn Ingle <donn.in...@gmail.comwrote:

Sheesh,我一直在努力寻找如何做这个简短的手:

如果0 x< 20:打印在...内
Sheesh, I''ve been going spare trying to find how to do this short-hand:
if 0 x < 20: print "within"



这意味着如果x小于0且x <0 20"

That means "if x LESS THAN 0 and x < 20".


>

因此x必须为0且< 20.
>
So that x must be 0 and < 20.



因此,如果0< b< b>那么请尝试
x< 20:

So try
if 0 < x < 20:


>

我通常这样做:

如果x 0和x< 20:打印内


规则是什么?它甚至存在吗?

我最近在列表上读到了类似的内容但是找不到它,那就是我想要尝试它的冲动从。我在文档中找不到任何东西,但

然后再次(imho)Python文档就像一个纠结的丛林......
>
I usually do:
if x 0 and x < 20: print "within"

What''s the rule? Does it even exist?
I read something like it recently on the list but can''t find it, that''s
where I got the urge to try it from. I can''t find anything in the docs, but
then again (imho) the Python docs are like a tangled jungle...



可能的手册:教程&参考

教程:检查内容,if statement和看起来可能,但没有运气

参考:检查内容,比较看起来很可能,并且
http://docs.python.org/ ref / comparisons.html 说:

"""

比较可以任意链接,例如x< y< = z相当于

到x< y和y< = z,除了y仅被评估一次(但是在两个

的情况下,当x< y被发现为假时,z根本不被评估)。

"""

Likely manuals: Tutorial & Reference
Tutorial: check contents, "if statement" looks possible, but no luck
Reference: check contents, "comparisons" looks possible, and
http://docs.python.org/ref/comparisons.html says:
"""
Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent
to x < y and y <= z, except that y is evaluated only once (but in both
cases z is not evaluated at all when x < y is found to be false).
"""


这篇关于如果填料测试范围基本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆