|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
>>> def MyFirstFunction():
print('创建的第一个函数')
print('\n')
print('结束')
>>> MyFirstFunction()
创建的第一个函数
结束
>>> def MySecondFunction(name):
print(name+'我爱你')
>>> MySecondFunction(99)
Traceback (most recent call last):
File "<pyshell#87>", line 1, in <module>
MySecondFunction(99)
File "<pyshell#86>", line 2, in MySecondFunction
print(name+'我爱你')
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> MySecondFunction('44')
44我爱你
>>> #为什么数值型的会报错???
>>> 66+'字符型'
Traceback (most recent call last):
File "<pyshell#90>", line 1, in <module>
66+'字符型'
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> #因为数字加字符型,不会自动转换成字符型?
>>>
|
|