我創(chuàng)建了一個(gè)class,用它實(shí)例化了多個(gè)什么東西(想不出詞了)我調(diào)用其中同一個(gè)的方法對(duì)他進(jìn)行操作的時(shí)候,別的也改變了為什么別的也會(huì)改變,我的確多次實(shí)例化了下面貼我精簡(jiǎn)后的代碼#coding:utf-8
import?urllib2
class?yv_root(object):
????html_wei=[]
????def?__init__(self,interim):
????????self.html_wei.append(interim)
????def?html_wei_read(self):
????????a?=?self.html_wei[0]
????????self.html_wei.pop(0)
????????return?a
????def?html_wei_add(self,interim):
????????self.html_wei.append(interim)
????def?inspect(self):
????????return?len(self.html_wei)
n0=yv_root('http://www.*****.com')
n1=yv_root('http://www.*****.cn:6001')
n2=yv_root('http://www.*****.cn:6002')
n3=yv_root('http://www.*****.cn:6003')
n4=yv_root('http://www.*****.cn:6004')
n5=yv_root('http://www.*****.cn:6005')
root=(n0,n1,n2,n3,n4)
i=0
while?i<5:
????root[i].html_wei_read()
????print?root[i].inspect()
????i=i+1
for?a?in?root:
????a.html_wei_read
????print?a.inspect()
關(guān)于python多次實(shí)例化
122138763238273
2017-08-10 21:19:08