Variables for getting started with python

name1 = "aa"

name2 = name1

print("My name is",name1,name2)

name1 = "bb"

print("My name is",name1,name2)

The first print outputs (aa, aa)

The second print outputs (bb, aa)

Note: Before the first print, name2 has obtained the value aa through name1, so it has already pointed to aa and has nothing to do with name1, so when the assignment of name1 changes, name2 will not follow it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324533109&siteId=291194637