isinstance类型记录在哪里?

编程入门 行业动态 更新时间:2024-10-09 05:23:02
本文介绍了isinstance类型记录在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用isinstance内置函数。我找到了它的文档, 但是支持的类型上没有文档。 例如isinstance(a,int)工作正常但isinstance(s,string) 不 - 因为''字符串未知''。 我知道如何导入类型模块,然后使用定义的类型 ,例如''types.StringType'' - 但文档说从2.2 这不是首选的方式。 那么,'我可以使用isinstance的类型的文档,例如'/ b $ b'为''int''? 非常感谢, Tony

Hi, I''m using the isinstance built-in function. I''ve found the docs for it, but there are no docs on the supported types. For example isinstance(a, int) works fine but isinstance(s, string) doesn''t - because ''string is not known''. I do know how to import the types module and then use defined types such as ''types.StringType'' - but the documentation says that from 2.2 this is not the preferred way. So, where''s the documentation for types I can use with isinstance, such as ''int''? Many thanks, Tony

推荐答案

codefire启发我们: codefire enlightened us with: 我正在使用isinstance内置函数。我找到了 的文档,但是支持的类型没有文档。 I''m using the isinstance built-in function. I''ve found the docs for it, but there are no docs on the supported types.

支持所有类型/类。

All types/classes are supported.

例如isinstance(a,int)工作正常但是isinstance(s,string) 不 - 因为''字符串未知''。 For example isinstance(a, int) works fine but isinstance(s, string) doesn''t - because ''string is not known''.

这是因为''string''不是一个类: print" abc" .__ class __.__ name__ 这个名字是''str'',而不是''string''。 Sybren - - Sybren St ?? vel St ?? vel IT - www.stuvel.eu/

2006年9月26日02:59:07 -0700,codefire< to **********@gmail写道: On 26 Sep 2006 02:59:07 -0700, codefire <to**********@gmailwrote: 我正在使用isinstance内置函数。我找到了它的文档, 但是支持的类型上没有文档。 例如isinstance(a,int)工作正常但isinstance(s,string) 不 - 因为''字符串未知''。 I''m using the isinstance built-in function. I''ve found the docs for it, but there are no docs on the supported types. For example isinstance(a, int) works fine but isinstance(s, string) doesn''t - because ''string is not known''.

在这种情况下,你想要str而不是字符串。 我找不到一个带有内置类型列表的页面( 不会意味着一个人不存在)但我认为你可以找到它们所有 挂在这个页面上:< docs.python/lib/types.html>。 - 干杯, Simon B, si *** @ brunningonline , www.brunningonline/simon/blog/

好​​的Simon,谢谢你链接,我想我可以从那里找出常见的 类型。 Tony OK Simon, thanks for that link, I think I can ferret out the common types from there. Tony

更多推荐

isinstance类型记录在哪里?

本文发布于:2023-11-12 14:38:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581764.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型   isinstance

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!