# 检查python对象类型

在python脚本中经常要转换变量类型，虽然同样是`12`，对于数值和字符串，其比较是完全不同的，非常容易忽略导致错误。

检查方法是使用`type()`功能：

```
>>> type([]) is list
True
>>> type({}) is dict
True
>>> type('') is str
True
>>> type(0) is int
True
>>> type({})
<type 'dict'>
>>> type([])
<type 'list'>
```

> 参考 [Determine the type of a Python object](http://stackoverflow.com/questions/2225038/determine-the-type-of-a-python-object)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/develop/python/startup/detect_python_object_type.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
