How can I loop through this dictionary instead of hardcoding the keys

后端 未结 4 1620
长发绾君心
长发绾君心 2021-01-21 18:47

So far, I have this code (from cs50/pset6/DNA):

import csv

data_dict = {}
with open(argv[1]) as data_file:
    reader = csv.DictReader(data_file)
    for record          


        
4条回答
  •  自闭症患者
    2021-01-21 19:32

    You can loop through a dictionary in python simply enough like this:

    for key in dictionary:
      print(key, dictionary[key])
    

提交回复
热议问题