2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

一度に複数のタイプに対して、isinstanceを調べる(Python)

Posted at

#概要
複数のタイプについて、isinstanceは一度に調べることができる。
#内容
##環境
macOS Catalina
Python 3.7.0
##実行
isinstanceの第二引数をtupleにすることで、可能となる。

>>> a = 8
>>> isinstance(a, str) or isinstance(a, int)
True
>>> isinstance(a, (str, int))
True

#参考にさせていただいた頁・本

#感想
便利。
#今後
機会があれば使っていきたい。

2
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?