Correct way to detect sequence parameter?

后端 未结 12 1555
情书的邮戳
情书的邮戳 2020-11-28 13:48

I want to write a function that accepts a parameter which can be either a sequence or a single value. The type of value is str, int, etc., but I don\'t want

12条回答
  •  感动是毒
    2020-11-28 14:13

    IMHO, the python way is to pass the list as *list. As in:

    myfunc(item)
    myfunc(*items)
    

提交回复
热议问题