li=[{'usename':'xiaowang'},
{'password':''}
]
board=['张三','李四','王大麻子']
while 1:
usename = input('用户名:')
if usename.upper()=='Q':break
password = input('密码:')
for i in board:
if i in usename:
usename=usename.replace(i,'*'*len(i))
li.append({'usename':usename,'password':password})
print({'usename':usename,'password':password})
print(li)
注意: for i in board:
if i in usename:
usename=usename.replace(i,'*'*len(i))