python.nlp essay (2) assignment

In the assignment operation, the value of a structured object (or function) is a reference to the object, which is different from the assignment operation of the expression value.

for example:

foo1 = 'monty'
bar1 = foo1
foo1 = 'Python'

foo2 = ['monty','Python']
bar2 = foo2
foo2[1]='Bodkin'

print(bar1,bar2)

def set_up(word,properties):
    word = 'lolcat'
    properties.append('noun')
    properties = 5

w = 'a'
p = []
set_up(w,p)
print(w,p)
output:
monty ['monty', 'Bodkin']
a ['noun']



Guess you like

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