Python sequence type

Source: Internet
Author: User

1. Immutable sequence types: tuple, range, str, set

001: There are several ways to construct a tuple type

1, () constructs an empty tuple.

2, a | (A,) constructs a tuple of only one element.

3, tuple (' 1 ') is constructed using the built-in tuple method.

4, (three-way) use the literal value method to construct a tuple.

002: There are not so many tricks for range, only one method of construction available in range (start index, end index, step)

003:str is not too much of a pattern; it is mainly constructed with literal values, which can be caused by single quotes, double quotes, and three quotation marks.

  

#!/usr/bin/python#!coding:utf-8if __name__=="__main__": A=[[] forIinchRange (6)] [a[0]='Neeky'a[1]="Neeky"a[2]=" "Neeky" "a[3]="""Neeky"""                            #the form of three quotation marks can be used to span multiple lines. a[4]="""Neeky""""""Neeky""" #the string in Python can be concatenated without the + sign, just write it to a piece. A[5]= ('Neeky'     'Neeky')#you can span more than one line, even if it's not a three-quote, plus parenthesis.      forXinchA:Printx

2. Variable sequence list,dict

Python sequence type

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.