Linux 拨号vps windows公众号手机端

python typeof函数的作用是什么

lewis 9年前 (2016-11-24) 阅读数 7 #程序编程
文章标签 python

typeof不是Python内置函数,正确的是使用type函数来获取对象的类型。type函数的作用是返回一个对象的类型。例如:

x = 5
print(type(x))  # <class 'int'>

y = "Hello"
print(type(y))  # <class 'str'>

z = [1, 2, 3]
print(type(z))  # <class 'list'>
版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门