Skip to content

Instantly share code, notes, and snippets.

@Everfighting
Created May 24, 2017 05:12
Show Gist options
  • Save Everfighting/4984c8eeb3f0d3b68f0f5a92135d06bb to your computer and use it in GitHub Desktop.
Save Everfighting/4984c8eeb3f0d3b68f0f5a92135d06bb to your computer and use it in GitHub Desktop.
python是强类型的语言,不是脚本语言就一定是弱类型语言。看Python与Javascript的对比。
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