type – 型を調べる



変数の型を調べるにはtypeを使います。

1
2
3
4
5
6
7
8
9
10
>>> type(1)
<type 'int'>
>>> type(1.0)
<type 'float'>
>>> type(100000000000000000)
<type 'long'>
>>> type("test")
<type 'str'>
>>> type(u"卵")
<type 'unicode'>

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Facebook comments:

comments

Leave a Reply


Get Adobe Flash player