2024-09-24 00:28:01 发布
网友
我对Python是个新手。你知道吗
我想创建一个包含两个向量的函数。我试过了
def twovectors((velocity1,length1),(velocity2,length2)):
但我有个信息错误
SyntaxError: invalid syntax.
求你了,我需要帮助。你知道吗
不能将tuple作为参数放入函数定义中。检查Python语言参考中的Multiple Function Arguments或8.6. Function definitions。你知道吗
尝试以下操作:
def twovectors(vector1, vector2): velocity1, length1 = vector1 velocity2, length2 = vector2 # Other code...
我使用tuple unpacking来扩展提供的元组参数。你知道吗
用python编写函数的方式如下:
def twovectors(velocity1, velocity2): # You can get the length of those vectors after you get inside the function len1, len2 = len(velocity1), len(velocity2) // Your code here return whateveryouwantto
不能将tuple作为参数放入函数定义中。检查Python语言参考中的Multiple Function Arguments或8.6. Function definitions。你知道吗
尝试以下操作:
我使用tuple unpacking来扩展提供的元组参数。你知道吗
用python编写函数的方式如下:
相关问题 更多 >
编程相关推荐