t***q 发帖数: 418 | 1 python 问题,急,在线等。要用python写一个function,function 有两个arguments,
这两个arguments是两个lists.该怎么写?
def function(list1, list2) not right,
def function(*list1,*list2) not right,
how to do it?
或是python function只容许有一个list argument?
Thank you so much! | l*********s 发帖数: 5409 | | L*****e 发帖数: 8347 | 3 第一种为啥说not right?
【在 t***q 的大作中提到】 : python 问题,急,在线等。要用python写一个function,function 有两个arguments, : 这两个arguments是两个lists.该怎么写? : def function(list1, list2) not right, : def function(*list1,*list2) not right, : how to do it? : 或是python function只容许有一个list argument? : Thank you so much!
| a9 发帖数: 21638 | 4 how about this?
def function(list1, list2):
【在 t***q 的大作中提到】 : python 问题,急,在线等。要用python写一个function,function 有两个arguments, : 这两个arguments是两个lists.该怎么写? : def function(list1, list2) not right, : def function(*list1,*list2) not right, : how to do it? : 或是python function只容许有一个list argument? : Thank you so much!
| a9 发帖数: 21638 | 5 缺了冒号吧,呵呵
arguments,
【在 L*****e 的大作中提到】 : 第一种为啥说not right?
| L*****e 发帖数: 8347 | 6 呃,那楼主的问题其实应该改改:如何定义一个python function? 呵呵。。。
【在 a9 的大作中提到】 : 缺了冒号吧,呵呵 : : arguments,
| t***q 发帖数: 418 | 7 多谢大家这么踊跃的回答。我很感激。
我后来找出原因了,def function(list1,list2):即可。
我有error的原因是数据不规整。即数据的列数不一样,就有error: IndexError: list
index out of range
多谢!多谢! |
|