妹妹猪
发表于 2020-5-14 11:45:20
"""新建用户名"""
N = input("请输入用户名:")
current_users=["admin","jason","peter","cindy","good"]
new_users=["jason", "隔壁老王", "Good", "peter"]
for N in new_users:
if N in new_users:
print("用户名已被使用")
else:
print("用户名未被使用")
pai123
发表于 2020-5-14 11:46:03
1
空条徐伦
发表于 2020-5-16 17:39:06
current_users = ['admin','Jason','Peter','WangJS','Good']
new_users = ['Jason','隔壁老王','wangjs','蔓越莓','Peter']
for i in new_users:
for z in current_users:
if i == z:
print(i,'已经被使用')
break
else:
print(i,'可以使用')
break
ForPorsche
发表于 2020-5-18 23:00:24
current_users = ['admin', 'Jason', 'Peter', 'WangJS', 'Good']
new_users = ['Jason', '隔壁老王', 'wangjs', '蔓越莓', 'PeteR']
x = ','.join(current_users)
for i in new_users:
if i.lower() in x.lower():
print(i, '已被使用')
else:
print(i, '没被使用')
天然呆丨
发表于 2020-5-19 17:32:46
current_users = ['admin','Jason','Peter','WangJS','Good']
new_users = ['Jason','隔壁老王','wangjs','蔓越莓','Peter']
for i in range(len(new_users)):
x=new_users in current_users
if x==True:
print("已被使用")
else:
print("未被使用")
噗呲。
发表于 2020-5-21 10:29:12
感谢分享!
妹妹猪
发表于 2020-5-22 15:21:15
for i in range(len(current_users))
为什么range里不能直接是列表 加上len什么作用?谢谢。
遁天入地1412
发表于 2020-5-22 17:13:19
{:5_109:}
0623009
发表于 2020-5-23 09:06:30
current_users = ["admin","jason","peter","wangjs","good"]
new_users = ["Jason","隔壁老王","WangJS","蔓越莓","peter"]
new = new_users[:]
current = current_users[:]
for i in range(len(new_users)):
new = new_users.lower()
for i in range(len(current_users)):
current = current.lower()
if new in current :
print(new_users+"已被使用,请输入其他用户名")
else:
print(new_users+"未被使用")
zwhe
发表于 2020-5-31 10:44:43
{:7_130:}
guenji
发表于 2020-6-4 21:41:40
'''检查新用户是否被使用'''
current_users = ['admin','Jason','Peter','WangJS','Good']
new_users = ['Jason','隔壁老王','wangjs','蔓越莓','Peter']
L = #将current_users中的字母转换成小写,并创建新的列表
for new_user in new_users:
if new_user.lower() in L:
print(new_user + ' 已被使用,请输入别的用户名')
else:
print(new_user + ' 未被使用。')
latiao-python
发表于 2020-6-9 22:40:57
current_users = ['王二小','张嘎子','小萝卜头','赖宁','王小er']
new_users = ['小蜘蛛','小班纳','小钢铁','王小Er','赖宁']
for i in new_users:
if i.casefold() in :
print(i,'已被占用')
else:
print(i,'没被占用')
latiao-python
发表于 2020-6-9 22:45:24
liuzhengyuan 发表于 2020-4-24 15:36
这个有点看不懂哪位大佬给解释下
孤独患者xp
发表于 2020-6-10 03:14:09
1
zhenxin051
发表于 2020-6-10 09:09:45
新手来学习学习
tyona
发表于 2020-6-10 16:47:34
1469396970 发表于 2020-4-24 17:27
current_users=['龟兄','fishlove','shy哥','clearlove100','uzi']
new_users=['硬币哥','龟兄','kangkang ...
current_users列表里的“uzi”如果换为“uZi”,可能结果就会有点小问题哦~
lznanjing
发表于 2020-6-10 18:17:53
current_users = ['admin','Jason','Peter','WangJS','Good']
new_users = ['Jason','隔壁老王','wangjs','蔓越莓','Peter']
s=str(current_users)
b=s.casefold()
for each in new_users:
if each.casefold() in b:
print(each,'已被使用')
else:
print(each,'没被使用')
土二奇
发表于 2020-6-11 18:44:46
new_users = ['Jason','隔壁老王','wangjs','蔓越莓','Peter']
current_users = ['admin','Jason','Peter','WangJS','Good']
for i in range(5):
ifnew_users.upper in :
print("%s 已经使用过"%new_users)
else :
print("%s 可以使用"%new_users)
世界你好吗
发表于 2020-6-11 21:53:20
小白来学习了
1469396970
发表于 2020-6-12 10:14:06
tyona 发表于 2020-6-10 16:47
current_users列表里的“uzi”如果换为“uZi”,可能结果就会有点小问题哦~
哈哈,是滴,我之后改了一下{:10_297:}