Is Python strongly typed?

后端 未结 11 1365
长发绾君心
长发绾君心 2020-11-22 17:12

I\'ve come across links that say Python is a strongly typed language.

However, I thought in strongly typed languages you couldn\'t do this:

bob = 1
b         


        
11条回答
  •  無奈伤痛
    2020-11-22 17:33

    i think, this simple example should you explain the diffs between strong and dynamic typing:

    >>> tup = ('1', 1, .1)
    >>> for item in tup:
    ...     type(item)
    ...
    
    
    
    >>>
    

    java:

    public static void main(String[] args) {
            int i = 1;
            i = "1"; //will be error
            i = '0.1'; // will be error
        }
    

提交回复
热议问题