-
Notifications
You must be signed in to change notification settings - Fork 5
/
dim_items.py
48 lines (37 loc) · 989 Bytes
/
dim_items.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# coding:utf-8
from my_const import *
'''
记录每个商品信息的类
'''
class Dim:
def __init__(self, item, cat, terms):
self.item = item
self.cat = cat
self.terms = terms
'''
读取并返回每商品的信息
'''
import logging
class DimItems:
def __init__(self, filename):
self.filename = filename
def read_in(self):
logging.debug("read in dim items")
dims = {}
num = 0
for line in open(self.filename):
line = line[:-1]
item, cat, name = line.split(" ")
terms = name.split(",")
dims[item] = Dim(item, cat, terms)
# print item, cat, name, terms
# print num
# num += 1
# if num == 2:
# break
logging.debug("finish reading dim items")
return dims
if __name__ == "__main__":
di = DimItems(FilePath.dim_items_filename)
dims = di.read_in()
print dims['41'].cat