我正在尝试将列表转换为元组.
当我谷歌它,我发现很多答案类似于:
l = [4,5,6]
tuple(l)
Run Code Online (Sandbox Code Playgroud)
但如果我这样做,我收到此错误消息:
TypeError:'tuple'对象不可调用
我该如何解决这个问题?
码:
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)