吳沛穎python,方法read(),seek(0),readlines(),input
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 x in line: # if line.find(x) != -1: 使用python更強的功能in
n += 1 # 被更常使用
print(n, ' ',line,end="")#預設結束換列
print(f'\n總共{n}題目')
Google找得到,期中考。https://yppp077.blogspot.com/2026/11/htmlcssjavascriptpython.html
回覆刪除Seek. https://yppp077.blogspot.com/2026/10/pythoninputfind-1.html