ファイルに参加して次のエラーが発生した後、リストのいくつかの値を書き込もうとしていますが、これを修正する方法についての入力はありますか?
data_changes ={'305403': ['302180'], '312994': ['311957'], '311957': ['312621'] }
modem_changes = {'305403': [], '313113': [], '312994': ['253036', '312591'], '311957': []}
dc_set = set(data_changes)
mc_set = set(modem_changes)
with open('file.txt', 'w+') as f:
for key in dc_set.intersection(mc_set):
union_values = data_changes[key] + modem_changes[key]
values = key, ','.join(union_values)
f.write(values)
with open('file.txt', 'a') as f:
for key in dc_set.symmetric_difference(mc_set):
dc_values = data_changes.get(key) or []
mc_values = data_changes.get(key) or []
union_values = dc_values + mc_values
values=key, ','.join(union_values)
f.write(values)
エラー:-
Traceback (most recent call last):
File "final_build_list.py", line 31, in <module>
f.write(values)
TypeError: argument 1 must be string or read-only character buffer, not tuple