• 周二. 3月 28th, 2023

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

python数据类型

admin

11月 28, 2021

类型判断

def typeof(variate):
    type1 = ""
    if type(variate) == type(1):
        type1 = "int"
    elif type(variate) == type("str"):
        type1 = "str"
    elif type(variate) == type(12.3):
        type1 = "float"
    elif type(variate) == type([1]):
        type1 = "list"
    elif type(variate) == type(()):
        type1 = "tuple"
    elif type(variate) == type({"key1":"123"}):
        type1 = "dict"
    elif type(variate) == type({"key1"}):
        type1 = "set"
    return type1

View Code

。。。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注