所以我几乎把这段代码写对了,因为它只是关于字典的。我遇到的唯一问题是错误是一元 + 的错误操作数类型:'str'。
这是我的代码:
express_file = {'TPLEX':'Pangasinan', 'SLEX':'Subic', 'Cavitex':'Bacoor,Cavite','MCX':'Muntinlupa','Star Tollway':'Laguna'}
for x,y in express_file.items():
print(x,'runs through',+y+ '.')
print('The following Expressway are included in this data set:')
for x in express_file.keys():
print(x)
print('\nThe following Provinces are included in this data set:')
for x in express_file.values():
print(x)
追溯
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-782fcd7b686e> in <module>
1 express_file = {'TPLEX':'Pangasinan', 'SLEX':'Subic', 'Cavitex':'Bacoor,Cavite','MCX':'Muntinlupa','Star Tollway':'Laguna'}
2 for x,y in express_file.items():
----> 3 print(x,'runs through',+y+ '.')
4 print('The following Expressway are included in this data set:')
5 for x in express_file.keys():
TypeError: bad operand type for unary +: 'str'
慕仙森
智慧大石
相关分类