Python中的Inplace vs Standard Operators
普通操作员执行简单的分配作业。另一方面,Inplace运算符的行为类似于普通运算符,除非它们在可变和不可变目标的情况下以不同的方式运行。
在这两种情况下,都需要分配来存储值。
# Python code to demonstrate difference between
# Inplace and Normal operators in Immutable Targets
# importing operator to handle operator operations
import operator
# Initializing values
x = 5
y = 6
a = 5
b = 6
# using add() to add the arguments passed
z = operator.add(a,b)
# using iadd() to add the arguments passed
p = operator.iadd(x,y)
# printing the modified value
print ("Value after adding using normal operator : ",end="")
print (z)
# printing the modified value
print ("Value after adding using Inplace operator : ",end="")
print (p)
# printing value of first argument
# value is unchanged
print ("Value of first argument using normal operator : ",end="")
print (a)
# printing value of first argument
# value is unchanged
print ("Value of first argument using Inplace operator : ",end="")
print (x)
三个资料Q群下载不了也转发不了,先放这里Fine_tuning.zipLangChain.zipdata_clear.rar