劉任昌python,方法read(),seek(0),readlines(),input,in

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://www.blogger.com/blog/post/edit/7117219004802242035/2765706405237430718

    回覆刪除
  2. https://leeenming.blogspot.com/2026/10/pythonreadseek0readlinesin.html

    回覆刪除
  3. https://chenjunjie592.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  4. https://wei-chen-chang.blogspot.com/2026/10/pythonreadseek0readlinesin.html

    回覆刪除
  5. https://liushaouchi.blogspot.com/2026/10/pythonreadseek0readlinesinput.html

    回覆刪除
  6. https://asdfgktifdjjej.blogspot.com/2026/10/pythonreadseek0readlinesin.html

    回覆刪除
  7. https://zhonghexiao.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除
  8. https://hsy08311111.blogspot.com/2026/10/pythonreadseek0readlinesin.html

    回覆刪除
  9. https://huangzhehui.blogspot.com/2026/10/pythonreadseekreadlines.html

    回覆刪除
  10. https://wangyuzhen.blogspot.com/2026/10/pythonreadseek0readlinesin.html

    回覆刪除
  11. https://zhiyao01.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  12. https://hsu1214328.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  13. https://jiexin0713.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  14. https://lzr0914.blogspot.com/2026/10/pythonreadseek0readseek0readlinesinputin.html

    回覆刪除
  15. https://huangpeiling16.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除
  16. https://yangxinzhen.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除
  17. 作者已經移除這則留言。

    回覆刪除
  18. https://griuyijglkrijlrtfgfgf.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  19. https://chenyueying.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除
  20. https://kuozhehao.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除
  21. https://wumeiyingying181818.blogspot.com/2026/10/pythonreadseek0.html

    回覆刪除
  22. https://www.blogger.com/blog/post/edit/7896241238449226961/2694554236198079735

    回覆刪除
  23. https://yubiyu.blogspot.com/2026/10/pythonreadseek0readlinesin.html

    回覆刪除
  24. https://ludingfeng.blogspot.com/2026/10/pythonreadseekreadlinesin.html

    回覆刪除
  25. https://huang-hsin-ju.blogspot.com/2026/10/pre-file-open.html

    回覆刪除
  26. https://wdwddq211223d.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  27. https://changjiahul.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  28. https://ryan052497.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  29. https://lin-takming.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  30. https://leexinni819.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  31. https://huang070207.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  32. https://dhyipgduwio3.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除
  33. https://yuuuyjghj.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html

    回覆刪除
  34. https://star2136.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌python字串方法in找到特定「題號」和題目

劉任昌Python產生金融常識Javascript測驗網頁

劉任昌EXCEL函數LEFT,MID,RIGHT及PYTHON方法FIND