Linux 拨号vps windows公众号手机端

python怎么查看变量类型

lewis 8年前 (2017-04-11) 阅读数 8 #程序编程
文章标签 python

可以使用type()函数来查看变量的类型。例如:

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

y = 3.14
print(type(y)) # 输出:<class 'float'>

z = "hello"
print(type(z)) # 输出:<class 'str'>

你可以根据需要将变量名替换为你自己定义的变量来查看其类型。

版权声明

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

发表评论:

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

热门