概要
str(オブジェクト)
- str(文字列)型へ変換。
- 組み込み関数
実行結果
int型
inte = 123456 print(type(inte)) print(type(str(inte))) print(str(inte))
表示イメージ
<class 'int'> <class 'str'> 123456
float型
flot = 0.123456 print(type(flot)) print(type(str(flot))) print(str(flot))
表示イメージ
<class 'float'> <class 'str'> 0.123456
list型
lst = [1, 2, 3] print(type(lst)) print(type(str(lst))) print(str(lst))
表示イメージ
<class 'list'> <class 'str'> [1, 2, 3]
tuple型
tpl = "りんご","みかん","バナナ" print(type(tpl)) print(type(str(tpl))) print(str(tpl))
表示イメージ
<class 'tuple'> <class 'str'> ('りんご', 'みかん', 'バナナ')
dict型
dic ={'睦月': 1, '如月': 2, '弥生': 3} print(type(dic)) print(type(str(dic))) print(str(dic))
表示イメージ
<class 'dict'> <class 'str'> {'睦月': 1, '如月': 2, '弥生': 3}