python dict()相关函数提问

问题遇到的现象和发生背景

为什么使用dict()函数第一种方法会出现报错,但是使用第二种不会出现报错

问题相关代码,请勿粘贴截图

dict3=dict([2,5],[3,4])
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    dict3=dict([2,5],[3,4])
TypeError: dict expected at most 1 argument, got 2


dict3=dict(([2,5],[3,4]))
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

字典类型只接收一个参数,dict((这里面是参数)),只有一层括号的时候你中间有逗号就是两参数

题主您好,字典时有两个参数 键和值,应该通过这种方式创建 dict3 = {键:值},如果你想按你的方式来的话要使用zip函数使他们一一对应。

>>> dict3 = dict(zip([2,5],[3,4]))
>>> dict3
{2: 3, 5: 4}

可见dict获得参数方式是
for i,k in canshu:传入的不是二位数组,是无法通过这种方式初始化字典的

dict1=dict(a=1,b=2)
dict2=dict([['a',1],['b',2],['c',3]])
dict3=dict({'a':1})
print(dict1,dict2,dict3)

class dict(object)
 |  dict() -> new empty dictionary
 |  dict(mapping) -> new dictionary initialized from a mapping object's
 |      (key, value) pairs
 |  dict(iterable) -> new dictionary initialized as if via:
 |      d = {}
 |      for k, v in iterable:
 |          d[k] = v
 |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
 |      in the keyword argument list.  For example:  dict(one=1, two=2)