Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
y=print (-2)
我可以在交互式 python 会话中运行上述命令吗?我在 Cygwin 中尝试过,但它给了我一个错误。
不,print函数返回None,所以y将是None。但是,-2将被打印。
print
None
y
-2
做就是了:
y = -2
只是为了咯咯笑,你可以这样做:
y = print
这将允许:
y(-2) > -2
print 是一个函数,不能存储在变量中。尝试这样的事情:
y = -2 print(y)
Print(y) 打印 y 中的任何内容(在本例中为 -2)