2014-03-24 30 views
-1

假设我在一个python shell中。我输入了= 10。如何清除python的shell值?

>>> a=10 
>>> a 
10 

但没有对C,我的意思是

>>> c 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
NameError: name 'c' is not defined 
>>> 

如何清除的值,因此其应该储存什么。我的意思是清除后,如果我按输出应该类似于C.

注意:不想离开python。

+0

是这样一个糟糕的问题吗?任何解释请。 – shekhar

+0

谁低估了你可能是因为如果你谷歌“蟒蛇清除价值”的答案是在第一个结果。 – DBedrenko

回答

2

del statement删除名称:

del a 

之后访问a将抛出一个NameError还有:

>>> a = 10 
>>> a 
10 
>>> del a 
>>> a 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
NameError: name 'a' is not defined 
+0

很快,谢谢。我需要等待一段时间才能接受。 – shekhar