python中print type的用法

python中print type的用法

一.
python中type() 函数返回对象的类型,print函数为打印结果,
验证如下,

1、WIN+R快捷键,打开运行窗口,准备进入python环境,
在这里插入图片描述
2、敲入python,进入python环境,如下,
在这里插入图片描述
3、分别敲入 type(1), type(‘a’), type([1,2]),输出分别为 int、str、list类型,
在这里插入图片描述
4、分别敲入print(type(1)), print(type(‘a’)), print(type([1,2]),输出如下,
在这里插入图片描述
二.
a=1
print type(a)
结果为 int 整型
a=“1”
print type(a)
结果为 str 字符串型type 输出类型

发布了9 篇原创文章 · 获赞 32 · 访问量 2387

猜你喜欢

转载自blog.csdn.net/qq_46698164/article/details/105389544