Python Data Type

Source: Internet
Author: User
Python supports the following data types: integer, floating point, plural, and string.
The plural value is represented by a "J" suffix. It can also be created through complex (Real, IMG. The real and virtual parts can be accessed separately. Like this: >>> C = complex (5, 3)
>>> C. Real
5.0
>>> C. imag
3.0
>>>

Character string operations are also quite special. 1 >>> word = "ABC"
2 >>> print word * 3
3 abcabcabc
4

You can also easily intercept strings.

>>> Sentence = "python is good"
>>> Sentence [8] # obtain the characters with the subscript of 8
'S'
>>> Sentence [] # obtain a string consisting of 10 to 14 subscripts.
'Good'
>>> Sentence [: 6] # obtain a string consisting of the first six characters
'Python'

Supports Unicode string Definition >>> U'hello \ u0020python'
U'hello python'

It also supports; linked list and Dictionary (equivalent to hash table) >>> List = ['you', 'are', 'bad'] # define a linked list using brackets
>>> List
['You', 'are', 'bad']
>>> Dict = {'you': 'bad', 'me': 'good'} # define the dictionary with curly brackets
>>> Dict ['you'] # Use brackets to access dictionary elements
'Bad'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.