我想讀取文件並提取記錄並在類中打印該文件。我得到的錯誤是該對象沒有函數追加?我已經將它聲明爲一個數組,但似乎沒有認出它。任何提示這個問題是關於什麼?這是解決問題的有效方法嗎?將元素附加到數組實例變量並打印出來 - Python
import os
class URL():
Test=[]
def read(self,file):
for l in open(file):
fields=l.split(',')
company=fields[1].replace(" ",'+')
adress="+".join((str(fields[5]),str(fields[11])))
self.Test.append("".join(("http://www.someurl/market-search?q=",company)))
def Print(self):
for i in Test:
return i
ROOT = os.getcwd()
START_URL=URL()
START_URL.read(ROOT+'\Company_Lists\Test_of_company.csv')
print START_URL.Print
您能給確切的錯誤你得到什麼? –
self.Test!=測試。你沒有定義self.Test – M4rtini
self.Test.append(「」.join((「http://www.someurl/marker-search?= company)))AttributeError'function'object has no attribute'append' –