code: def gen_random_bank_card(bankname, card_type):
      
      bank_info = CardBin.get_bank_info(bankname)
      if not bank_info:
          raise ValueError('bankname {} error, check and try again'.format(bankname))
  
      # 获取银行代码
      bank = bank_info[0][0]
  
      # 获取 cardbin
      cardbin_info = CardBin.get_cardbin_info(bank, card_type)
      if not cardbin_info:
          raise ValueError('card_type {} error, check and try again'.format(card_type))
  
      random_cardbin = random.choice(cardbin_info)
  
      cardbin = random_cardbin[0]
      card_len = random_cardbin[-1]
  
      # 银行卡前缀
      card_number_str = cardbin
  
      # 随机生成前N-1位
      while len(card_number_str) < card_len - 1:
          card_number_str += str(random.randint(0, 9))
  
      # 获取校验位
      check_code = CardBin.get_checkcode(card_number_str)
      return card_number_str + check_code
docs: 通过指定的银行名称，随机生成该银行的卡号
  
      :param:
          * bankname: (string) 银行名称 eg. 中国银行
          * card_type：(string) 卡种类，可选 CC(信用卡)、DC(借记卡)
  
      :returns:
          * random_bank_card: (string) 随机生成的银行卡卡号
  
      举例如下::
  
          print('--- gen_random_bank_card demo ---')
          print(gen_bank_card('中国银行', 'CC'))
          print(gen_bank_card('中国银行', 'DC'))
          print('---')
  
      输出结果::
  
          --- gen_random_bank_card demo ---
          6259073791134721
          6212836989522229131
          ---