Python values and strings

Source: Internet
Author: User

Python data type

1. Value--type: 1/integral type

2/Long Integer type

3/Float Type--0.0, 12.0, -18.8, 3e+7, etc.

4/plural type--complex

In [10x34alout[1842L--0x34a -- indicates 16 binary --l   -- Represents a long integer type
In [2]: 4e+7out[240000000.0in[3]: type (4e+7  ) out[3float--Scientific counting method
in [4]: B ="Hello\nlulu"In [6]: bout[6]:'Hello\nlulu'In [7]: Print Bhellolulu--it has a newline character and prints it out in the [8]: a =" "Hello...: Lulu" "In [9]: aout[9]:'Hello\nlulu'In [Ten]: Print Ahellolulu---Triple quotes-can be double quotes or single quotes-table interpretation so that you can automatically load line multibyte, do not need to write their own

2. String--is a sequence--the operation of the sequence can be indexed and sliced

in [7]: B ='OPLKDJ'In [8]: bout[8]:'OPLKDJ'In [Ten]: b[0]out[Ten]:'o'In [ One]: b[4]out[ One]:'D'In [ A]: b[-1]out[ A]:'J'In [ -]: b[-3]out[ -]:'k'==========================/*Take two characters*/In [ -]: b[0]+b[4]out[ -]:'od'In [ the]: b[0:3]                --starting from the No. 0, Fetch 3, the third does not show out[ the]:'OPL'

in [2]: a ='ABCDE'In [3]: aout[3]:'ABCDE'In [4]: a[1:2]out[4]:'b'In [5]: a[:]out[5]:'ABCDE'In [6]: a[:-1]out[6]:'ABCD'--0 to the last one, but not the last in [7]: a[:2]out[7]:'AB'--[:2] The default colon to the left is 0In [8]: a[-1]out[8]:'e'In [9]: a[1:] out[9]:'BCDE'--from number 1th to the last
in [Ten]: a[:-1]out[Ten]:'ABCD'In [ One]: a[::-1]out[ One]:'EDCBA'In [ A]: a[::1]out[ A]:'ABCDE'In [ -]: a[::2]out[ -]:'Ace'In [ -]: a[::]out[ -]:'ABCDE'

3. List

4. Tuples

5. Dictionaries

Python values and strings

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.