Ich lerne die Python und ich stieß hier auf ein neues Problem. Kann jemand diesen Python-Code erklären, was genau intern passiert?String Verkettung schlägt fehl
>>> s="sam"
>>> s +="dam"
>>> s
'samdam'
>>> d +=s
>>> d
'msamdam'
>>> f = f+s
Traceback (most recent call last):
File "<pyshell#129>", line 1, in <module>
f = f+s
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> f +=s
Traceback (most recent call last):
File "<pyshell#130>", line 1, in <module>
f +=s
TypeError: unsupported operand type(s) for +=: 'int' and 'str'
Was ist f in Ihrem Code? – HH1
Könnten Sie Ihren Code aktualisieren, um die Instanziierungen von d und f einzuschließen? – Fabien