`
zsjg13
  • 浏览: 146109 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论

Identifying Data Types

 
阅读更多

    你可以在运行时检查任何对象的数据类型,这样你的程序就能够正确处理不同类型的数据(例如,一个 int 函数,你传给它一个整数、浮点数、字符串,等等,它都能工作)。用 type(obj) 就能获取任何对象的类型:

>>> type(5)

<type ‘int’>

>>> type(‘She sells seashells’)

<type ‘string’>

>>> type(operator)

<type ‘module’>

    types 模块包含了Python内置数据类型的 type objects。

>>> import types

>>> def upEm(words):

...     if type(words) != types.ListType: # Not a list so

...          words = [words]              # make it a list.

...     for word in words:

...          print word.upper()

>>> upEm(‘horse’)

HORSE

>>> upEm([‘horse’,’cow’,’sheep’])

HORSE

COW

SHEEP

    classes 的 Classes 和 instances 分别拥有类型 ClassType 和 InstanceType。

>>> isinstance(5.1,types.FloatType)

1

>>> class Foo:

...  pass

... 

>>> a = Foo()

>>> isinstance(a,Foo)

1

分享到:
评论

相关推荐

    Translational Biomedical Informatics

    identifying different types of sequence variants from NGS data. We summarize the common approaches for analyzing and visualizing casual variants associated with complex diseases on precision medicine ...

    c-programming-for-scientists-and-engineers-manufacturing-engineering-series

    The chapter begins with an overview of the fundamental concepts of variables and data types in C programming. It introduces the basic syntax and semantics of declaring and initializing variables. ###...

    Syngree Press:Managing Catastrophic Loss of Sensitive Data A Guide for IT and Security Professionals(Mar 2008).pdf

    - **Types of Sensitive Data:** - Personal Identifiable Information (PII): Includes names, addresses, Social Security numbers, etc. - Financial Information: Credit card details, bank account numbers...

    Oracle Database 10g PL-SQL Programming

    - **Data Types**: Overview of various data types available in PL/SQL, including numeric, character, date, and interval types. - **Control Structures**: Detailed explanation of loops (FOR, WHILE), ...

    基于python爬虫的菜价可视化系统源码数据库论文.docx

    6. **Analysis and Insights**: Statistical methods are applied to analyze the crawled data, identifying correlations between factors like vegetable prices, market demand, and seasonal trends....

    The.Mobile.Application.Hackers.Handbook.epub

    * Understand the ways data can be stored, and how cryptography is defeated * Set up an environment for identifying insecurities and the data leakages that arise * Develop extensions to bypass ...

    11g_plsql_user_guide_and_reference.pdf

    Three new data types have been introduced: `SIMPLE_INTEGER`, `SIMPLE_FLOAT`, and `SIMPLE_DOUBLE`. These data types provide a more efficient way to store simple numeric values. `SIMPLE_INTEGER` is ...

    计算机网络 - Networking-Fundamentals-by-Crystal-Panek

    Identifying Types of LANs 20 Getting to Know Perimeter Networks 23 Identifying Network Topologies and Standards 25 Identifying Network Topologies 25 Defining Ethernet Standards 29 Identifying the ...

    Beginning PHP 5.3

    - **Data Types:** Comprehensive overview of PHP data types, including scalar types (integer, float, string, boolean) and compound types (arrays, objects). - **Operators:** Description of different ...

    Objective-C for Absolute Beginners iPhone, iPad, and Mac Programming Made Easy

    - **Programming Basics**: Covers the fundamental concepts of programming, such as variables, data types, and control structures. - **It’s All About the Data**: Explains how to manage and manipulate ...

    SAP BW Tables

    - Identifying and resolving performance bottlenecks. #### VariablesforProcessChainsforRuntime (RSPCRUNVARIABLES) **Purpose:** This table stores variables used during the runtime of process chains, ...

    C++性能优化 指南(强列推荐) chm版

    The Standard C/C++ Variables Variable Base Types Grouping Base Types Summary Chapter 7. Basic Programming Statements Selectors Loops Summary Chapter ...

    USB Complete 3rdEdition

    Device Endpoints: the Source and Sink of Data 38 Pipes: Connecting Endpoints to the Host 40 Types of Transfers 40 Stream and Message Pipes 42 Initiating a Transfer 43 Transactions: the Building Blocks...

    用户画像推荐系统springboot设计和实现 计算机专业.pdf

    Different users have different preferences for different types of news. When a user repeatedly searches for news with certain specific characteristics, the system automatically filters out this ...

    现代数字通信论文1

    The performance analysis conducted in the paper not only evaluates the overall accuracy but also investigates the sensitivity of the algorithm to different types of images. This is essential for ...

    Unsupervised Learning by Probabilistic Latent Semantic Analysis

    The paper presents perplexity results for different types of text and linguistic data collections, demonstrating substantial and consistent improvements of the probabilistic method over standard ...

    python3.6.5参考手册 chm

    Data Instead Of Unicode Vs. 8-bit Overview Of Syntax Changes New Syntax Changed Syntax Removed Syntax Changes Already Present In Python 2.6 Library Changes PEP 3101: A New Approach To String ...

    Quick Time File Format

    A box is defined by a header that includes a four-character code (fourcc) identifying the type of box and the size of the box, followed by the box data itself. Here's a breakdown: - **Header**: ...

    Microsoft Library MSDN4DOS.zip

    Chapter 5 Defining and Using Complex Data Types Chapter 6 Using Floating-Point and Binary Coded Decimal Numbers Chapter 7 Controlling Program Flow Chapter 8 Sharing Data and Procedures among Modules ...

Global site tag (gtag.js) - Google Analytics