python是弱类型语言吗?不是的,python属于强类型的动态脚本语言
强类型:不予许不同类型相加
动态:不使用显示数据声明类型,且确定一个变量的类型是第一次给他赋值的时候
脚本语言:一般也是解释性语言,运行代码只需要一个解释器,不需要编译
这里对强类型和弱类型进行对比:
python代码:
>>> 3+69>>> "3"+6traceback (most recent call last): file "<stdin>", line 1, in <module>typeerror: can't convert 'int' object to str implicitly>>> "3"+"6"'36'>>> "6"-"3"traceback (most recent call last): file "<stdin>", line 1, in <module>typeerror: unsupported operand type(s) for -: 'str' and 'str'
javascript代码:
3+69"3"+6"36""3"+"6""36""6"-"3"3
以上就是python是弱类型语言吗的详细内容。