まぬねこの足跡。。。

備忘録+たのしさ+ひっそりと

Python - type():データ型の確認

概要

type(オブジェクト)

  • データ型の確認
  • 組み込み関数

実行結果

int型

inte = 123456

print(type(inte))
type(inte)

表示イメージ

<class 'int'>
int

float型

flot = 0.123456

print(type(flot))
type(flot)

表示イメージ

<class 'float'>
float

string型

strg = "ABCD"

print(type(strg))
type(strg)

表示イメージ

<class 'str'>
str

list型

lst = [1, 2, 3]

print(type(lst))
type(lst)

表示イメージ

<class 'list'>
list

tuple型

tpl = "りんご","みかん","バナナ"

print(type(tpl))
type(tpl)

表示イメージ

<class 'tuple'>
tuple

dict型

dic ={'睦月': 1, '如月': 2, '弥生': 3}

print(type(dic))
type(dic)

表示イメージ

<class 'dict'>
dict