作者查詢 / LongboardDC

總覽項目: 發文 | 留言 | 暱稱
作者 LongboardDC 在 PTT [ Python ] 看板的留言(推文), 共23則
限定看板:Python
看板排序:
首頁
上一頁
1
下一頁
尾頁
[閒聊] 請問list如何忽略大小寫
[ Python ]22 留言, 推噓總分: +4
作者: doris15 - 發表於 2021/09/20 19:48(4年前)
1FLongboardDC: login是一個list, 沒有.lower() method09/20 20:13
2FLongboardDC: 你可以使用list comprehension:09/20 20:14
3FLongboardDC: login_lower = [x.lower() for x in login]09/20 20:14
4FLongboardDC: 同樣的方法可以得到user_lower09/20 21:05
5FLongboardDC: 你後面的for loop有logical error09/20 21:05
6FLongboardDC: 我假設你的目的是要檢查user_lower裡的每個名字,09/20 21:06
7FLongboardDC: if名字是amanda, 印出Welcome back.09/20 21:06
8FLongboardDC: elif名字在login_lower裡, 印出Welcome, tourist.09/20 21:06
9FLongboardDC: else印出Please register your account.09/20 21:06
10FLongboardDC: for loop應修正為:09/20 21:07
11FLongboardDC: for i in user_lower:09/20 21:07
12FLongboardDC: (………內部交給你修改)09/20 21:07
13FLongboardDC: 這樣第一次: i 為 ‘kevin’09/20 21:08
14FLongboardDC: 第二次: i為’dora’09/20 21:08
15FLongboardDC: 第三次: i為’chris’09/20 21:08
16FLongboardDC: 第四次: i為’amanda’09/20 21:08
17FLongboardDC: 第五次: i 為’mary’09/20 21:08
用python將Excel某一行資料直接匯出txt檔
[ Python ]26 留言, 推噓總分: +12
作者: assassin2191 - 發表於 2021/09/12 21:53(4年前)
19FLongboardDC: 我的桌面有個檔案叫pokemon_data.xlsx09/20 23:51
20FLongboardDC: https://i.imgur.com/VOlW03d.jpg09/20 23:52
21FLongboardDC: 我想要把Name那行資料匯出txt檔09/20 23:53
22FLongboardDC: https://i.imgur.com/TpiYHIH.jpg09/20 23:53
23FLongboardDC: 現在我的桌面出現了一個叫poke_names.txt的檔案09/20 23:54
24FLongboardDC: https://i.imgur.com/b66DDOz.jpg09/20 23:54
首頁
上一頁
1
下一頁
尾頁