![](/img/trans.png)
[英]Take words from one file, find it in second and if found write whole line in third file using Python
[英]find one criteria in my file and print the whole line python
def beginner():
fileName = "classmarks.csv"
myfile = open(fileName, "r")
userResults = []
if "beginner" in line
print (line)
myfile.close()
這是我的嘗試,但我不確定這是否有效,並且正在尋找更好的方法來做到這一點 function
你可以試試:
def beginner():
fileName = "classmarks.csv"
with open(fileName, "r") as fobj:
data = fobj.readlines()
for line in data:
if "beginner" in line:
print(line)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.