我有一个文本文件名为“movies.txt”那里面是那些台词:Python库函数问题
The_Godfather Francis_Ford_Coppola Crime 1972
The_Dark_Knight Christofer_Nolan Action 2008
Pulp_Fiction Quentin_Tarantino Drama 1994
从文件我想提取这些行,并与其他功能(按年份搜索使用它们/ genere ect)。 要打开我使用的文件:
f=open("movies.txt","r")
s=f.read()
print(s)
f.close()
但似乎我缺少的东西,这里是代码的样本:
f=open("movies.txt","r")
s=f.read()
print(s)
f.close()
def search_movie_by_name(name,path):
mystring = path
for i in path:
if word in mystring:
print("Found")
它是什么做的代码?或者我如何打开它?
你能不能给我们一个[完整的示例](https://stackoverflow.com/help/mcve)如何你正在运行/调用它? – Gerrat
那么你得到的输出或错误是什么? – Adonis
def search_movie_by_name(Baywatch,path): 这是你的意思吗? – Tom