所以我是一名初学者程序员,并且学习编程:在cousera上制作高质量的代码课程。我有一个文件restaurant_small.txt
如何将项目从Python中的文件分配给字典?
restaurant.txt格式是餐厅的评价,
georgieporgie:50
dumpling r us:70
queens cafe:60
我可以通过线上阅读线
dictionary = {}
our_file = open(file)
#using an iterator to read files
for line in iter(our_file):
dictionary = ??
我希望能够建立一个字典{'restaurant':'rating'}
我该如何解决这个问题,一步一步赞赏
,如果你不介意的话,你能解释线两条 – 2013-04-04 12:37:28
@SuziemacTani添加了解释,并参考了很多感谢 – 2013-04-04 12:42:46
,港岛线接受的答案,我不能现在... – 2013-04-04 12:46:12