オブジェクトが文字列のリストかどうかを確認する方法は? オブジェクトが文字列であるかどうかのみを確認できました。
def checktype(obj):
if isinstance(obj,str):
print "It's a string"
obj1 = ['foo','bar','bar','black','sheet']
obj2 = [1,2,3,4,5,'bar']
obj3 = 'bar'
for i in [obj1,obj2,obj3]:
checktype(i)
望ましい出力:
It's a list of strings
It's not a list of strings or a single string
It's a single string