許舒涵python輸入input尋找find沒找到-1

file = open('金融常識.txt','r',encoding='utf-8')
lines = file.readlines()
file.seek(0)#讀完readlines()記憶體指標回到檔案開頭
reading = file.read() #上個星期read()是讀取所有字元
file.close()
print(len(lines),len(reading))
x = input('許舒涵輸入搜尋關鍵詞,列出所有題目: ')
n=0
for line in lines:
   if x in line: # if line.find(x) != -1: 使用python更強的功能in
      n +=1 # 被更常使用
      print(n,'',line,end="")#預設結束換列
print(f'\n總共{n}題目')

留言

  1. 商業軟體。https://dhyipgduwio3.blogspot.com/2026/11/excelvlookupindirectctrl-shift-enter.html
    google「許舒涵python」找到成大、台北商業大學、德明科大許舒涵。金融市場測驗順利執行。https://dhyipgduwio3.blogspot.com/2026/11/javascript.html
    補足過去作業.https://dhyipgduwio3.blogspot.com/2026/11/pythonlistset372411251.html
    期中考試。https://dhyipgduwio3.blogspot.com/2026/11/htmlcssjavascriptpython.html
    python seek().https://dhyipgduwio3.blogspot.com/2026/10/pythonin.html
    input.https://dhyipgduwio3.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

乙班許舒涵w3schools學習python字串list串列set集合dict字典