相关疑难解决方法(0)

在Python中检查类型的规范方法是什么?

检查给定对象是否属于给定类型的最佳方法是什么?如何检查对象是否继承给定类型?

假设我有一个对象o.我如何检查它是否是一个str

python types

1171
推荐指数
12
解决办法
80万
查看次数

TypeError:'str'对象不可调用(Python)

码:

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)

python

59
推荐指数
10
解决办法
48万
查看次数

标签 统计

python ×2

types ×1