关于作者

Discuss / Python / TypeError: Can't convert 'int' object to str implicitly

TypeError: Can't convert 'int' object to str implicitly

Topic source

白-日-梦-想-家-

#1 Created at ...

d = {'x': 'A', 'y': 'B', 'z': 'C' } print([k + '=' + v for k, v in d.items()]) 这段在运行的时候报了TypeError: Can't convert 'int' object to str implicitly,请问哪边错了呢,代码都是直接复制的..

Arleyzhang

#2 Created at ...

阅读要认真。。。

Linux熊

#3 Created at ...

没看出来哪里有问题, 并且测试也是通过的

>>> d = {'x': 'A', 'y': 'B', 'z': 'C' }
>>> [k + '=' + v for k, v in d.items()]
['x=A', 'y=B', 'z=C']

akipa11

#4 Created at ...

不用加print了吧?


  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.