NBAfile = open ('nbafile.txt', 'r')
count = 0
NBAList = []
for line in NBAfile:
textline=line.strip()
items = textline.split()
NBAList.append(items)
team, att, price = NBAList[0]
attendances = []
for line in NBAList:
attendances.append(int(line[1]))
prices = []
for (team, att, price) in NBAList:
prices.append(float(price))
teams = []
for (team, att, price) in NBAList:
teams.append(team)
'In the City of %s the number of people who attended were %s and the cost
of a ticket was %s' %(teams, attendances, prices)
我正在尝试使用格式化的字符串,我认为我确实在结尾处创建了该句子,它始终为我提供列表,而不是将其分开。像下面一样
[20.06, 22.54, 17.0, 21.98, 19.63, 17.05, 17.4, 24.42, 17.04, 17.56,
13.77, 21.95, 29.18, 17.6, 14.08, 10.92, 13.31, 22.7, 20.47, 19.04,
16.59, 22.19, 16.96, 16.79, 18.11]
我想念的是它不会将每一列分开或拉进去吗?