金一乙蔡昕辰python,read(),seek(0),readlines(),input,in

file = open('金融常識.txt','r',encoding='utf-8')
lines = file.readlines()
file.close()
x = input('蔡昕辰輸入搜尋關鍵詞: ')
for line in lines:
   if line.find(x) != -1: print(line,end="")
   file = open('金融常識.txt','r',encoding='utf-8')
lines = file.readlines()
file.seek(0)#讀完readlines()記憶體指標回到檔案開頭
reading=file
file.close()
print(len(lines),len(reading))
x = input('蔡昕辰輸入搜尋關鍵詞: ')
n = 0
for line in lines:
  if x in line: # if line.find(x) != -1: 使用phtyon更強的功能
        n=n+1
        print(n,' ',line,end='')
print(f'總共{n}題') #jun0724
  
  

留言

  1. GOOGLE「蔡昕辰PYTHON」找到https://star2136.blogspot.com/2026/11/htmlcssjavascriptpython.html
    商業軟體。https://star2136.blogspot.com/2026/10/excel.html
    程式設計。https://star2136.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

蔡昕辰EXCEL函數MATCH,LARGE,COUNTIF