code: def dict2csv(data_dict, csv_filename='./dict2csv.csv', key_is_header=False):
  
      
      with open(csv_filename, "w") as csv_file:
          csv_writer = csv.writer(csv_file)
          if key_is_header:
              if isinstance(data_dict, dict):
                  csv_writer.writerow(list(data_dict.keys()))
                  csv_writer.writerow(list(data_dict.values()))
              elif isinstance(data_dict, list) and all([isinstance(item, dict) for
                                                        item in data_dict]):
                  for item in data_dict:
                      csv_writer.writerow(list(item.keys()))
                      csv_writer.writerow(list(item.values()))
              else:
                  raise ValueError('data_dict should be a dict or list which member is dict, '
                                   'but we got {}'.format(data_dict))
          else:
              csv_writer.writerows(data_dict.items())
      return csv_filename
docs: 将字典写入到指定的 csv 文件，并返回文件的长文件名；
  
      :param:
          * data_dict: (dict) 需要写入 csv 的数据字典
          * csv_filename: (string) csv 文件的长文件名
          * key_is_header: (bool) csv 文件第一行是否全为字典 key
      :return:
          * csv_filename: (string) csv 文件的长文件名
  
      举例如下::
  
          from fishbase.fish_csv import *
  
          def test_dict2csv():
              data_dict = {'a': 1, 'b': 2}
              csv_file = dict2csv(data_dict)
              print(csv_file)
  
  
          if __name__ == '__main__':
              test_dict2csv()