NightSingle 2020-12-29 11:50 采纳率: 100%
浏览 49
已采纳

python字典中加入元组为什么加不进去

>>> student={}
>>> student["1"]="1"
>>> student
{'1': '1'}
>>> student("2")="2"
SyntaxError: cannot assign to function call
 

为什么元组不能这么加入字典

  • 写回答

2条回答 默认 最新

  • PythonJavaC++go 2020-12-29 12:34
    关注

    student["1"]="1"; 这里的中括号是索引而不是列表,python的索引都是使用中括号。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?