Home >Backend Development >Python Tutorial >Is python a weakly typed language?
Is python a weakly typed language? No, Python is a strongly typed dynamic scripting language
Strong type: does not allow the addition of different types
Dynamic: does not use explicit data to declare the type, and determines the value of a variable The type is when it is assigned a value for the first time
Script language: It is generally an interpreted language. Running the code only requires an interpreter and does not require compilation
Here is a comparison between strong typing and weak typing:
python code:
>>> 3+6 9 >>> "3"+6 Traceback (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 code :
3+6 9 "3"+6 "36" "3"+"6" "36" "6"-"3" 3
The above is the detailed content of Is python a weakly typed language?. For more information, please follow other related articles on the PHP Chinese website!