Is Python strongly typed?

后端 未结 11 1412
长发绾君心
长发绾君心 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:32

    You are confusing 'strongly typed' with 'dynamically typed'.

    I cannot change the type of 1 by adding the string '12', but I can choose what types I store in a variable and change that during the program's run time.

    The opposite of dynamic typing is static typing; the declaration of variable types doesn't change during the lifetime of a program. The opposite of strong typing is weak typing; the type of values can change during the lifetime of a program.

提交回复
热议问题