Created
May 24, 2017 05:12
-
-
Save Everfighting/4984c8eeb3f0d3b68f0f5a92135d06bb to your computer and use it in GitHub Desktop.
python是强类型的语言,不是脚本语言就一定是弱类型语言。看Python与Javascript的对比。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Python强类型:不同类型不能够进行运算。 | |
| >>> 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弱类型:不同类型可以进行运算。 | |
| 3+6 | |
| 9 | |
| "3"+6 | |
| "36" | |
| "3"+"6" | |
| "36" | |
| "6"-"3" | |
| 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment