郭旻諺python輸入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)
 
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)
        n=n+1
        print(n,' ',line,end=' ')
 print(f'總共{n}題')
 

留言

  1. 商業軟體期中考。英文沒有隔開。https://julian696969.blogspot.com/2026/11/excelformulas.html
    商業軟體。https://julian696969.blogspot.com/2026/10/excelandorcountcountifindirect.html
    1109.計算機,必須將style的body設定的vh拿掉。https://julian696969.blogspot.com/2026/11/html-css-javascript.html
    程式設計期中考。沒有嵌入影片。https://julian696969.blogspot.com/2026/11/htmlcssjavascriptpython.html
    readline. https://julian696969.blogspot.com/2026/10/pythoninputfind-1_0206097737.html
    https://julian696969.blogspot.com/2026/10/pythoninputfind-1.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

郭旻諺python集合set字典dict統計字元數目37.241不同字元數1.251

郭旻諺w3schools字串str串列list集合set字典dict元組tuple

郭旻諺EXCEL函數MATCH,INDEX,ISNUMBER