-
Notifications
You must be signed in to change notification settings - Fork 2
/
put_food_list.py
62 lines (57 loc) · 1.55 KB
/
put_food_list.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'''
width = 4
header_format = '%-*s%s(%s)'
format = '%-*s%s(%s)'
print header_format %(width,'No.','Item','Price')
food_list = open("food_list",'rU')
for line in food_list :
food_number = line.split(',')[0]
food_name = line.split(',')[1]
food_price = line.split(',')[2]
print format % (width,food_number,food_name,food_price)
food_list.close()
'''
def printfood():
flag = False
width = 4
header_format = '%-*s| %s(%s)'
format = '<%s> %-12s(%s)'
print header_format %(width,'<No.>','Item','Price')
print '-*-'*6
food_list = open("food_list",'r')
for line in food_list :
food_number = line.split(',')[0]
food_name = line.split(',')[1]
food_price = line.split(',')[2]
if flag :
print format % (food_number,food_name,food_price)
else:
print format % (food_number,food_name,food_price),
print ' | ',
flag = not flag
food_list.close()
def print_food(self):
width = 4
header_format = '%-*s| %s(%s)'
format = '<%s>%s(%s)'
print header_format %(width,'<No.>','Item','Price')
print '-*-'*6
food_list = open("food_list",'r')
for line in food_list :
food_number = line.split(',')[0]
food_name = line.split(',')[1]
food_price = line.split(',')[2]
temp_sendLine = format % (food_number,food_name,food_price)
self.sendLine(temp_sendLine)
food_list.close()
def findfood(n):
temp = None
food_list = open("food_list",'rU')
for line in food_list :
food_number = int(line.split(',')[3])
food_name = line.split(',')[1]
if food_number == n :
temp = food_name
return temp
food_list.close()
printfood()