[英]Call argument from multi returned arguments function using Python
By using Python: I want to call just one argument from defined function (Angles) which return two arguments theta and phi.通过使用 Python:我只想调用定义的 function(角度)中的一个参数,它返回两个 arguments theta 和 phi。 How can I call just theta value from Angles funcition and assign it to x value?
如何从 Angles 函数中调用 theta 值并将其分配给 x 值?
values = [1,-1]
g = np.random.choice(values)
q= np.random.choice(values)
def Angles ():
theta = (((1 + g*g - ((1 - g*g)/(1 - g + 2*g*q))**2)/(2*g)))
phi = 2 * math.radians(180) * q
return theta,phi
x = cos(theta)
You have to call Angles
first;您必须先致电
Angles
; theta
will be the first element of the tuple returned by Angles
. theta
将是Angles
返回的元组的第一个元素。
th, ph = Angles()
x = cos(th)
or或者
x = cos(Angles()[0])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.