Detect types in python2

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Detect types in python2相关的知识,希望对你有一定的参考价值。

 1 >>> type(bonjour)
 2 <type str>
 3 >>> type(type(bonsoir))
 4 <type type>
 5 >>> dir(_)
 6 [__abstractmethods__, __base__, __bases__, __basicsize__, __call__, __class__, __delattr__, __dict__, __dictoffset__, __doc__, __eq__, __flags__, __format__, __ge__, __getattribute__, __gt__, __hash__, __init__, __instancecheck__, __itemsize__, __le__, __lt__, __module__, __mro__, __name__, __ne__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasscheck__, __subclasses__, __subclasshook__, __weakrefoffset__, mro]
 7 >>> type(2**100).__name__
 8 long
 9 >>> if isinstance(what up, (complex, float, int, long, str)): True
10 
11 True
12 >>> type(123) == type(23333333333333333)
13 False
14 >>> type(123) == type(233)
15 True

There is also a module called types.

1 >>> import types
2 >>> dir(types)
3 [BooleanType, BufferType, BuiltinFunctionType, BuiltinMethodType, ClassType, CodeType, ComplexType, DictProxyType, DictType, DictionaryType, EllipsisType, FileType, FloatType, FrameType, FunctionType, GeneratorType, GetSetDescriptorType, InstanceType, IntType, LambdaType, ListType, LongType, MemberDescriptorType, MethodType, ModuleType, NoneType, NotImplementedType, ObjectType, SliceType, StringType, StringTypes, TracebackType, TupleType, TypeType, UnboundMethodType, UnicodeType, XRangeType, __builtins__, __doc__, __file__, __name__, __package__]

Three key properties of all python objects: (ID, TYPE, VALUE)

 

以上是关于Detect types in python2的主要内容,如果未能解决你的问题,请参考以下文章

Detect Changes in Network Connectivity

Detect Cycle In Directed/Undirected Graph

在过滤器中使用str_detect和&的短手。

TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to

 FPGA边沿检测Verilog代码

TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to