Check if input is a list/tuple of strings or a single string

前端 未结 9 1234
执念已碎
执念已碎 2020-12-24 05:13

I\'ve a method that I want to be able to accept either a single string (a path, but not necessarily one that exists on the machine running the code) or a list/tuple of strin

9条回答
  •  死守一世寂寞
    2020-12-24 05:32

    Can't you do:

    (i == list (i) or i == tuple (i))
    

    It would reply if the input is tuple or list. The only issue is that it doesn't work properly with a tuple holding only one variable.

提交回复
热议问题