1. 使用 `type()` 函数:
variable = "Hello"
variable_type = type(variable)
print(variable_type) 输出:
2. 使用 `isinstance()` 函数:
variable = "Hello"
is_string = isinstance(variable, str)
print(is_string) 输出:True
`type()` 函数会返回变量的确切类型,而 `isinstance()` 函数则会检查变量是否为特定类的实例或其子类的实例。