Python: copy of a variable

后端 未结 5 1254
[愿得一人]
[愿得一人] 2020-12-10 13:33

Is there a way in to make copy of a variable so that when the value changes of variable \'a\' it copies itself to variable \'b\'?

Example

a=\'hello\'         


        
5条回答
  •  误落风尘
    2020-12-10 14:03

    There is an ugly way to create an independent copy of a simple variable via a temporary list:

    a = 6; 
    b = [a][0]
    

提交回复
热议问题