|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
大佬们
python作业就是导入一个CSV文件,文件有6列(title, authors, groups, keywords, topics, abstract)
作业要求就是输入author名字,然后python给出title和topicc
author这一列中,作者名字都是有很多个,如( Zhongqi Lu, Yin Zhu, Sinno Pan, Evan Xiang, Yujing Wang and Qiang Yang),输入一个正确的就可以返回title和topic
我的代码如下,但是怎么都不会返回title 和topic
import csv
with open('[UCI] AAAI-14 Accepted Papers - Papers-1.csv','r',encoding="utf-8") as in_file:
text = in_file.read()
author = input("What's the name of author?")
for line in text:
if author in line:
print("Title:",line[0],"Topics",line[4])
你试一下,我对这些英文字符串 还真不敏感,看着头晕
- import csv
- author=input("请输入作者名:")
- with open("wp.csv") as f:
- data=csv.reader(f)
- headers=next(data)
- for row in data:
- if author in row[1].split(","):
- print("title=",row[0])
- print("topic=",row[4])
-
复制代码
|
|