我正在尝试像以下那样获取数据,但是我遇到了一个逻辑错误,该错误与content * 2
相乘,但是,我看不到错误。我的字典内容是以下格式。我现在在获取数据时做错了什么?
AU dict
Melbourne
Canberra
Sydney
Hobart
Brisbane
公司
4INFO
Adbot
Adform
Adobe Systems
ADTECH
Adtile Technologies
Afilias
Alawar Entertainment
Amazon.com
AppNexus
Badgeville
BrightRoll
comScore
countries = {
'AU': open('AU','r').read().splitlines(),
'BE': open('BE','r').read().splitlines(),
'CA': open('CA','r').read().splitlines(),
'CH': open('CH','r').read().splitlines(),
'CZ': open('CZ','r').read().splitlines(),
'DE': open('DE','r').read().splitlines(),
'ES': open('ES','r').read().splitlines(),
'FR': open('FR','r').read().splitlines(),
'GB': open('GB','r').read().splitlines(),
'IE': open('IE','r').read().splitlines(),
'IT': open('IT','r').read().splitlines(),
'MX': open('MX','r').read().splitlines(),
'NL': open('NL','r').read().splitlines(),
'NZ': open('NZ','r').read().splitlines(),
'PL': open('PL','r').read().splitlines(),
'RO': open('RO','r').read().splitlines(),
'RU': open('RU','r').read().splitlines(),
'SE': open('SE','r').read().splitlines(),
'SG': open('SG','r').read().splitlines(),
'US': open('US','r').read().splitlines(),
}
companies = open('companies.txt','r').read().splitlines()
jobs = ['business+analyst','data+scientist']
for company in companies:
for country in countries:
for i in countries[country]:
for job in jobs:
tail = ""
print("using {} {}{}".format(country, company, tail))
输出
using AU 0
using AU 0
using AU 0
using AU 0
using AU 0
using AU 0
using AU 0
using AU 0
using AU 0
using AU 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
我希望当前输出为
using AU 0
using AU 0
using AU 0
using AU 0
using AU 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
using BE 0
在您写的注释中,您想打印company country city job
。
查看AU dict
似乎有一个城市列表,然后循环for i in countries[country]:
列出了城市。只需使用已有的内容即可打印company country city job
:
for company in companies:
for country in countries:
for city in countries[country]: # i renamed to city for better readability
for job in jobs:
print("{} {} {} {}".format(company, country, city, job))