許婕歆python,方法read(),seek(0),readlines(),input,in

file = open('金融常識.txt','r',encoding='utf-8')
lines = file.readlines()
file.seek(0)
reading= file.read()
file.close()
print(len(lines),len(reading))
x = input('金一乙許婕歆輸入搜尋關鍵字,列出所有題目: ')
n=0
for line in lines:
   if line.find(x) != -1:
    n = n+1
    print(line,end='\n')
print(f'總共{n}題目')

留言

  1. readlines. https://jiexin0713.blogspot.com/2026/10/pythonreadseek0readlinesinputin.html
    python in. https://jiexin0713.blogspot.com/2026/10/pythonin.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

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

許婕歆EXCEL產生網頁