gpt4 book ai didi

python - 如何打印 Python 类?

转载 作者:太空狗 更新时间:2023-10-30 00:56:45 25 4
gpt4 key购买 nike

<分区>

我有一个包含多个函数的类(其中大部分包含解析 smth.、获取所有必要信息并打印它的代码)。我正在尝试打印一个类,但我得到了 smth。像 <_main_.TestClass 实例在 0x0000000003650888>。代码示例:

from lxml import html
import urllib2
url = 'someurl.com'


class TestClass:

def testFun(self):
f = urllib2.urlopen(url).read()
#some code

print 'Value for ' +url+ ':', SomeVariable

def testFun2(self):
f2 = urllib2.urlopen(url).read()
#some code

print 'Value2 for ' +url+ ':', SomeVariable2

test = TestClass()
print test

当我在类外打印函数时 - 一切正常。我做错了什么以及如何打印类(class)?

谢谢!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com