我有這樣的代碼:如何連接的元組
def make_service(service_data, service_code):
routes =()
curr_route =()
direct =()
first = service_data[0]
curr_dir = str(first[1])
for entry in service_data:
direction = str(entry[1])
stop = entry[3]
if direction == curr_dir:
curr_route = curr_route + (stop,)
print((curr_route))
當我打印((curr_route)),它給了我這樣的結果:
('43009',)
('43189', '43619')
('42319', '28109')
('42319', '28109', '28189')
('03239', '03211')
('E0599', '03531')
如何讓一個元組?即 ('43009','43189', '43619', '42319', '28109', '42319', '28109', '28189', '03239', '03211', 'E0599', '03531')
下面的示例適用於我,是否可以在'if'節之前更改'curr_route'? – Arman
我不能評論underestand,請將其添加到問題中! – Arman
@drowningincode使用完整代碼更新您的問題 – Forge