Python implemented randomly generated card number, card number and password information output

Randomly generated bank card number, card number and password information output

Topics requirements:

  1. 100 randomly generated card;
    card beginning 6,102,009, followed by three back (001, 002, 003, 100),
  2. Dictionary generated on bank card number, the initial default password for each card number is "redhat";
  3. Output card number and password information in the following format:
  卡号                   密码 
6102009001             000000

Here Insert Picture Description

code show as below:

card_ids = []


# 生成100个卡号
for i in range(100):
    # %.3d:代表整数的占位
    s = '6102009%.3d' %(i+1)
    card_ids.append(s)

card_ids_dict = {}.fromkeys(card_ids,'redhat')
print(card_ids_dict)
print('卡号\t\t\t\t\t密码')
for key in card_ids_dict:
    print('%s\t\t\t%s' %(key,card_ids_dict[key]))

Output:
Here Insert Picture Description

Generated a total of 100 results

Published 60 original articles · won praise 6 · views 1362

Guess you like

Origin blog.csdn.net/weixin_45775963/article/details/103695835