【发布时间】:2011-08-24 23:21:46
【问题描述】:
在下面的代码中:
def modify_note(self):
id = input("Enter a note id: ")
memo = input("Enter a memo: ")
tags = input("Enter tags: ")
if memo:
self.notebook.modify_memo(id, memo)
if tags:
self.notebook.modify_tags(id, tags)
memo 和 tags 是字符串类型变量。 if 之后怎么写,python 在这里把它们当作布尔值吗?
【问题讨论】:
-
这是 Python 3.x 吗?
input()在 2.x 和 3.x 中有不同的含义。 -
请注意:除非您使用的是 python 3,否则请小心使用 input()!它与 raw_input 不同,因为它评估您输入的任何输入,相当于 eval(raw_input())!
-
是的,它是 python 3.x。 python 3 中的 raw_input 发生了什么?
-
"python 3 中的 raw_input 发生了什么?"这是一个无关的问题。首先,搜索堆栈溢出。然后阅读 Python 网站中的 Python 3 说明。这不是什么秘密。请阅读所有可用信息。
标签: python string boolean conditional-statements