boost怎么获取变量类型
时间: 2024-05-05 17:16:06
浏览: 133
在 Python 中,可以使用[内置](https://geek.csdn.net/educolumn/3ab6c130815e287f3c961c21cf111c40?spm=1055.2569.3001.10083)[[函数](https://geek.csdn.net/educolumn/2319d2a62911adc34b96ea572d8225a2?spm=1055.2569.3001.10083)](https://geek.csdn.net/educolumn/ba94496e6cfa8630df5d047358ad9719?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDQ0MDg2MiwiZXhwIjoxNzA3MzcxOTM4LCJpYXQiOjE3MDY3NjcxMzgsInVzZXJuYW1lIjoid2VpeGluXzY4NjQ1NjQ1In0.RrTYEnMNYPC7AQdoij4SBb0kKEgHoyvF-bZOG2eGQvc&spm=1055.2569.3001.10083) `type()` 来获取变量的[类型](https://geek.csdn.net/educolumn/2f8e8df4d4a5ce5581ebfcbeb16e1298?spm=1055.2569.3001.10083)。例如:
```python
x = 5
print(type(x)) # [输出](https://geek.csdn.net/educolumn/5cd6786a0b73a4d4d27fd638d84e2587?spm=1055.2569.3001.10083) <class 'int'>
y = "hello"
print(type(y)) # 输出 <class 'str'>
z = [1, 2, 3]
print(type(z)) # 输出 <class 'list'>
```