问题描述
- 这段python代码错在哪里了
- from datetime import date
import re
class iRates:
def init(selfdayrates):
self._day=day
self._rates=ratesclass ratesTable:
def init(self):
self._icon=[]
self._tcon=[]
def iadd(selfirates):
self._icon.append(irates)
def tadd(selftrate):
self._tcon.append(trate)
def getIrate(self):
return self._icon
def getTrate(self):
return self._tcondef getIconFromTxt(selftxtFile):
with open(txtFile) as f:
for line in f:
r=re.findall(r'd+.?d*'line)
if r and (len(r)==10):
d=date(int(r[0])int(r[1])int(r[2])
#p=iRates(dmap(floatr[3:]))
self.iadd(iRates(dmap(floatr[3:])))a=ratesTable()
a.getIconFromTxt('ls.txt')
for i in a.getIrate():
print(i._dayi._rates)
解决方案
到底是代码本身有错,还是功能有错,需要描述清楚
解决方案二:
读写的文件什么内容,程序要做什么,怎么不对,输出什么错误,什么都不说。
解决方案三:
from datetime import date
import re
class iRates:
def init(selfdayrates):
self._day=day
self._rates=rates
class ratesTable:
def init(self):
self._icon=[]
def add(selfirates):
self._icon.append(irates)
def getIrate(self):
return self._icon
def test(self):
f=open('ls.txt')
for line in f:
r=re.findall(r'd+.?d*'line)
if r and (len(r)==10):
d=date(int(r[0])int(r[1])int(r[2])
self.add( iRates(dmap(floatr[3:])) )
f.close()
if name =='__main__':
a=ratesTable()
a.test()
for i in a.getIrate():
print(i._dayi._rates)
解决方案五:
self.add( iRates(dmap(floatr[3:])) )
^
SyntaxError: invalid syntax