|

楼主 |
发表于 2023-3-23 21:48:14
|
显示全部楼层
本帖最后由 lzb1001 于 2023-3-23 21:51 编辑
>>> favorite = ‘Fishc’
>>> print(*favorite, sep='&')
F&i&s&h&c
>>> print(**favorite, sep='&')
Traceback (most recent call last):
File "<pyshell#72>", line 1, in <module>
print(**favorite, sep='&')
TypeError: print() argument after ** must be a mapping, not str # 返回错误提示:**后面的参数必须是一个映射,而不能是一个字符串
然而我测试如下时:
>>> a = {'one':1, 'two':2}
>>> print(a)
{'one': 1, 'two': 2}
>>> print(*a, sep = '&')
one&two # 为何返回结果仅仅是key键,而不包含value值?
>>> print(**a, sep = '&') # 为何返回错误提示?
Traceback (most recent call last):
File "<pyshell#80>", line 1, in <module>
print(**a, sep = '&')
TypeError: 'one' is an invalid keyword argument for print() |
|