file = open('金融常識.txt','r',encoding='utf-8')
lines = file.readlines()
file.seek(0) #讀完readlines()記憶體指標回到檔案開頭
reading = file.read() #上個星期read()是讀取所有字元
file.close()
total=len(lines)
print(total, len(reading))
x = input('莊欣穎輸入搜尋關鍵詞,列出所有題目: ')
n = 0
for i in range(total): #迴圈使用數字0到503
if x in lines[i]: # if line.find(x) != -1: 使用python更強的功能in
n += 1 # 被更常使用
print(n, '題號',i+1,lines[i],end="")#預設結束換列
print(f'\n總共{n}題目')
檔案 常用 插入 版面配置 公式 資料 校閱 檢視 說明 File Home Insert Page Layout Formulas Data Review View Help 插入函數 自動加總 最近用過的函數 財務 邏輯 文字 日期和時間 查閱與參照 數學與三角函數 其他函數 Insert Function AutoSum Recently Used Financial Logical Text Date & Time Lookup Reference MatH Trinomial More Functions
留言
張貼留言