真是假 [英] True of False

查看:81
本文介绍了真是假的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试写一个真假的If语句而且没有得到任何东西吗?我读过一些以前的帖子,但我一定不能错过

的东西。我只是尝试了一些简单的方法:


a = [" a,b,c,d,e,f]


如果c在a == True:

打印是


当我运行它时,它运行,但没有任何打印。我做错了什么?

谢谢。




I tried writing a true and false If statement and didn''t get
anything? I read some previous posts, but I must be missing
something. I just tried something easy:

a = ["a", "b", "c", "d", "e", "f"]

if "c" in a == True:
Print "Yes"

When I run this, it runs, but nothing prints. What am I doing wrong?
Thanks.

Kou

推荐答案

9月27日,上午11:33,kou ... @ hotmail.com写道:
On Sep 27, 11:33 am, kou...@hotmail.com wrote:

我尝试写一个真假If语句并且没有什么都没有?b $ b?我读过一些以前的帖子,但我一定不能错过

的东西。我只是尝试了一些简单的方法:


a = [" a,b,c,d,e,f]


如果c在a == True:

打印是


当我运行它时,它运行,但没有任何打印。我做错了什么?

谢谢。



I tried writing a true and false If statement and didn''t get
anything? I read some previous posts, but I must be missing
something. I just tried something easy:

a = ["a", "b", "c", "d", "e", "f"]

if "c" in a == True:
Print "Yes"

When I run this, it runs, but nothing prints. What am I doing wrong?
Thanks.

Kou





你可能想要包括paren(a中的c)和小写的p

打印,即打印,它应该工作


所以例如:

a = [" a,b,c,d,e,f]


if(c在a中)== True:

print" Yes"

,
You may want to include paren around ("c" in a) and a lower case p for
Print, i.e. print, and it should work

so eg:
a = ["a", "b", "c", "d", "e", "f"]

if ("c" in a) == True:
print "Yes"

2007年9月27日星期四09:33:34 -0700,koutoo写道:
On Thu, 27 Sep 2007 09:33:34 -0700, koutoo wrote:

我尝试写一个真假If语句并没有'''得到

什么?我读过一些以前的帖子,但我一定不能错过

的东西。我只是尝试了一些简单的方法:


a = [" a,b,c,d,e,f]


如果c在a == True:

打印是


当我运行它时,它运行,但没有任何打印。我究竟做错了什么?
I tried writing a true and false If statement and didn''t get
anything? I read some previous posts, but I must be missing
something. I just tried something easy:

a = ["a", "b", "c", "d", "e", "f"]

if "c" in a == True:
Print "Yes"

When I run this, it runs, but nothing prints. What am I doing wrong?



哇奇怪:


在[265]中:a = list(''abcdef'')


[266]:a

Out [266]:[''a'',''b'','c'', '''',''e'',''f'']


在[267]中:'''''在'$ b $'中出[267]:正确


在[268]中:''c''在==真实

出[268]:错误

在[269]中:('''c''在a)==真实

Out [269]:正确


在[270]中:'''''(a == True)

----------------------- -------------------------------------------------- -

< type''exception.TypeError''Trailback(最近一次调用最后一次)


/ home / bj /< ipython consolein<模块>()

< type''exception.TypeError''>:类型''bool''的参数不可迭代

什么'要去那儿吗?


Ciao,

Marc''Blac kJack''Rintsch

Wow that''s odd:

In [265]: a = list(''abcdef'')

In [266]: a
Out[266]: [''a'', ''b'', ''c'', ''d'', ''e'', ''f'']

In [267]: ''c'' in a
Out[267]: True

In [268]: ''c'' in a == True
Out[268]: False

In [269]: (''c'' in a) == True
Out[269]: True

In [270]: ''c'' in (a == True)
---------------------------------------------------------------------------
<type ''exceptions.TypeError'' Traceback (most recent call last)

/home/bj/<ipython consolein <module>()

<type ''exceptions.TypeError''>: argument of type ''bool'' is not iterable
What''s going on there?

Ciao,
Marc ''BlackJack'' Rintsch




kou ... @ hotmail.com写道:

kou...@hotmail.com wrote:

我试着写一个真假的If语句而且没有得到任何东西吗?我读过一些以前的帖子,但我一定不能错过

的东西。我只是尝试了一些简单的方法:


a = [" a,b,c,d,e,f]


如果c在a == True:

打印是


当我运行它时,它运行,但没有任何打印。我做错了什么?

谢谢。



I tried writing a true and false If statement and didn''t get
anything? I read some previous posts, but I must be missing
something. I just tried something easy:

a = ["a", "b", "c", "d", "e", "f"]

if "c" in a == True:
Print "Yes"

When I run this, it runs, but nothing prints. What am I doing wrong?
Thanks.

Kou



你好,

只需尝试:


a = [" a"," b"," c"," d"," e"" f" ;]

如果c在a:

打印是 


这将作为声明''" c"在一个''本身是真的。你可以通过输入c来尝试
在翻译处。


问候,

Shriphani Palakodety

Hello,
Just try :

a = ["a","b","c","d","e","f"]
if "c" in a:
print "yes"

That is going to work as the statement ''"c" in a'' itself is true. You
could try that by typing "c" in a at the interpreter.

regards,
Shriphani Palakodety


这篇关于真是假的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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