as everyone knows Python It's dynamic language , Variables can be assigned dynamically , The parameter variables of a function can also be changed dynamically , But sometimes write the following code :
# Learning algorithm notes - Cai Junsheng (qq:9073204)
#https://mysoft.blog.csdn.net/
#2020-10-30
def add(x, y):
return x + y
print(add(1,2))
print(add(1, 'abc'))
Suddenly there was a mistake , To catch you by surprise , The error prompt is as follows :
Traceback (most recent call last):
File "D:/work/ITA/src/im_tkinter_39.py", line 9, in <module>
print(add(1, 'abc'))
File "D:/work/ITA/src/im_tkinter_39.py", line 6, in add
return x + y
TypeError: unsupported operand type(s) for +: 'int' and 'st