简体   繁体   English

来自 multi 的调用参数返回 arguments function 使用 Python

[英]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.

相关问题 使用从函数返回的文件作为python中另一个函数的参数 - Using a file returned from a function as an argument for another function in python 使用 arguments 调用 python function 并在自动热键中获取返回值 - Call python function with arguments and get returned value in autohotkey Call Python function with arguments using HTML in Django - Call Python function with arguments using HTML in Django 使用返回函数的变量作为另一个函数的参数 - Using variables from a returned function as arguments in another function 如何从python调用带有Char**参数和int*参数的C方法? - how to call C methods with Char** argument and int* arguments from python? 使用返回值作为 function 参数 - Using a returned value as a function argument 将C函数中的指针参数与python脚本中的ctype参数链接起来 - Linking pointer arguments from a C function with a ctype argument in python script Python lambda用作参数,从父函数调用其他参数 - Python lambda used as an argument, calling other arguments from parent function 如何调用 function 和 arguments 在 ZA7F5F35426B9237411FCZ2317B 中使用另一个 function - How to call a function with arguments using another function in Python Python 3:如何从另一个文件调用函数并将参数传递给该函数? - Python 3: How to call function from another file and pass arguments to that function ?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM