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.close()
x = input('劉任昌輸入搜尋關鍵詞: ')
n = 0
for line in lines:
    if line.find(x) != -1: 
        n=n+1
        print(n,' ',line,end='')
print(f'總共{n}題')
file = open('金融常識.txt','r',encoding='utf-8')
lines = file.readlines()
file.close()
x = input('劉任昌輸入搜尋關鍵詞: ')
n = 0
for line in lines:
    if x in line:
        n=n+1
        print( n, ' ', line,end='')
print(f'總共{n}題')
file = open('金融常識.txt','r',encoding='utf-8')
reading = file.read()
file.seek(0) #回到檔案的開始
lines = file.readlines()
file.close()
print('read()方法讀共', len(reading), 'readlines()方法讀共', len(lines))
x = input('劉任昌輸入搜尋關鍵詞: ')
n = 0
for line in lines:
    if x in line:
        n=n+1
        print( n, ' ', line,end='')
print(f'總共{n}題')

留言

  1. 商業軟體,沒有表格
    格。https://trfbvuytrgoij.blogspot.com/2026/11/excelformulas.html
    這個錯誤,必須在HTML模式貼上才能執行。https://trfbvuytrgoij.blogspot.com/2026/09/blog-post.html
    補以前的.https://trfbvuytrgoij.blogspot.com/2026/11/file-open.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

張善喆EXCEL公式Formulas