package csv
import csv
f = open('chinese.csv','r')
chinese_dict = csv.reader(f)
for row in chinese_dict:
print row[0],row[1]
csv.reader
with open(filename,'r') as f:
for line in csv.reader(f):
eng_chn_dict = dict()
with open('chinese.csv','r') as f:
for row in csv.reader(f):
eng_chn_dict[row[0]] = row[1:] # note use of the slice operator
#
#if print row, it's like this: ['thank you', '\xe8\xb0\xa2\xe8\xb0\xa2', '\xe8\xb0\xa2\xe8\xb0\xa2\xe4\xbd\xa0']
#
word = raw_input('Enter English word to translate, or "quit" to quit: ')
while word.lower() != 'quit':
if word in eng_chn_dict.keys():
print "'{}' in Chinese has the following translation(s):".format(word)
translations = eng_chn_dict[word]
for translation in translations:
print translation
else:
print "'{}' is not in the dictionary.".format(word)
word = raw_input('Enter English word to translate, or "quit" to quit: ')
print "Thank you for playing!"