我真的不能想到为什么python需要del关键字(并且大多数语言似乎没有类似的关键字).例如,不是删除变量,而是可以分配None给它.从字典中删除时,del可以添加方法.
是否有任何理由保留delpython,或者它是Python垃圾收集前几天的遗迹?
所以,我想"恶"的东西奈德Deily在他的回答中提到这里.现在我认为类型True现在总是为假.如何在交互式窗口中反转此操作?
不要这样做:
True = False
Run Code Online (Sandbox Code Playgroud)
由于True现在已被False完全覆盖,因此似乎没有明显的回溯方式.是否存在True来自的模块,我可以执行以下操作:
True = <'module'>.True
Run Code Online (Sandbox Code Playgroud) 码:
import urllib2 as u
import os as o
inn = 'dword.txt'
w = open(inn)
z = w.readline()
b = w.readline()
c = w.readline()
x = w.readline()
m = w.readline()
def Dict(Let, Mod):
global str
inn = 'dword.txt'
den = 'definitions.txt'
print 'reading definitions...'
dell =open(den, 'w')
print 'getting source code...'
f = u.urlopen('http://dictionary.reference.com/browse/' + Let)
a = f.read(800)
print 'writing source code to file...'
f = open("dic1.txt", "w")
f.write(a)
f.close()
j = open('defs.txt', 'w')
print 'finding definition is source …Run Code Online (Sandbox Code Playgroud) 我set在交互式python会话中使用它作为变量名称而意外地覆盖了 - 有没有什么办法可以在set不重新启动会话的情况下访问原始函数?
(我在那个会话中有很多东西,我宁愿不必这样做,虽然我当然可以在必要的时候.)
我犯了一个错误如下:
>>> list = ['a', 'b', 'c']
Run Code Online (Sandbox Code Playgroud)
但现在我想使用内置函数list().如您所见,listname list和内置函数之间存在命名冲突list().
list如果不重新启动Python shell,我如何使用内置函数而不是变量?