1 Star 0 Fork 1

pish7/stdpython

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
a02.py 337 Bytes
一键复制 编辑 原始数据 按行查看 历史
pish7 提交于 2025-11-30 16:41 +08:00 . python
answer = 42
# type() 函数返回数据的类型
print(type(answer)) # <class 'int'>
if type(answer) is int:
print("What's the question?")
# 当需要进行这种检查时,最好使用 isinstance() 而不是 type(),
# 因为 isinstance() 考虑了子类和继承
if isinstance(answer, int):
print("What's the question?")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/pish7/stdpython.git
git@gitee.com:pish7/stdpython.git
pish7
stdpython
stdpython
master

搜索帮助