我怎样才能重写这个程序,所以我把所有的 data.txt 放到一个列表中,这样我就可以在城市之后搜索并使用列表对象和属性获取该城市的时间和本地时间?
数据.txt
City1
Time1
Local1
--------------
City2
Time2
Local2
--------------
City
Time
Local
--------------
City3
Time3
Local3
--------------
程序
class store:
def __init__(self, city, time, local):
self.city = city
self.time = time
self.local = local
def readfile():
row = "start"
list = []
infile = open("data.txt", "r", encoding="utf-8")
while row != "":
row = infile.readline()
list.append(rad)
infile.close()
store.readfile()