【发布时间】:2016-02-14 23:44:10
【问题描述】:
我正在编写一个程序,根据用户输入显示有多少人使用特定的电子邮件提供商。我有一个 CSV 文件,每次运行程序时都会打印0。
我的代码如下:
user = input('Enter an email'):
c=0
f_in = open('us-500.csv','r')
f_in.readline()
for line in f_in:
line = line.strip(' ')
first, last, company, address, city, country, state, zip, phone1, phone2, email, web = line.split(',')
for count in email:
if count == user:
c +=1
print(c)
f_in.close()
【问题讨论】:
-
改为
user = int(input('Enter an email:'))
标签: python csv python-3.x