python自動化第三天-python2

來源:互聯網
上載者:User

標籤:pos   str   lis   range   使用者名稱   ==   過多   and   提示   

list 迴圈

words=‘marry,lily,joker‘
for i in words:#每次從list裡邊拿一個值過來給i
print (i)
結果:

m
a
r
r
y
,
l
i
l
y
,
j
o
k
e
r

 

lists=[‘張流量‘,‘裡外反‘,‘牛旺鮮‘,‘琪琪‘]
# for #迴圈在迴圈可迭代對象的時候,每次迴圈的是裡邊的每一個元素
for name in lists:
if type(name)==lists:#判斷類型,判斷是否屬於lists
for i in name:
print(i)
print(name)
結果:

張流量
裡外反
牛旺鮮
琪琪

 

練習:

#註冊
#輸入帳號密碼
#如果帳號存在的,提示已經被註冊,如果不存在的,就讓他註冊
#不可為空
#使用者名稱長度6-12
#最多輸入3次
all_user=[‘牛韓陽‘,‘梁潘‘,‘張三‘,‘李四435345‘,‘123456‘]
# print (len(all_user))#取個數,長度
for i in range(3):
username=input(‘請輸入帳號:‘).strip()
if len(username)>5 and len(username)<13:
if all_user.count(username)>0:
print(‘使用者名稱已存在‘)
else:
print(‘趕緊註冊吧‘)
break
else:
print(‘使用者名稱長度不合法!長度6-12之間!‘)
else:
print(‘失敗,次數過多‘)

python自動化第三天-python2

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.