陳玫瑄輸入input尋找find沒找到-1

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: print(line,end='')
      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. 日期和時間Date and Time必須更正,截圖不夠完整。https://serein-chen.blogspot.com/2026/11/excelformulas.html
    1030.https://serein-chen.blogspot.com/2026/10/excelandorcountcountifindirect.html
    沒有嵌入影片。https://serein-chen.blogspot.com/2026/11/htmlcssjavascriptpython.html
    https://serein-chen.blogspot.com/2026/10/inputfind-1.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

陳玫瑄python集合set字典dict統計字元數目37,241不同字元數1,251

陳玫瑄excel字串處理產生金融市場常識