What types of variables do python have? and a summary of the variable types

Source: Internet
Author: User
Tags delete key

What types of variables do python have? and a summary of the variable types
"Numeric" number:float, int, long, complex

"String": str Note that there is no string, where STR is the abbreviation of string.
How to create: Str () a= ' abcdef '
Method:
1, interception: a[head Subscript: Tail Subscript: Each step value] The default is: 1
2. Increase: A + a equals a*2
3. Merger: A + A
4, S.lower () #小写
5, S.upper () #大写
6, S.swapcase () #大小写互换
7, S.capitalize () #首字母大写
Reference Address: http://blog.sina.com.cn/s/blog_5dd2af0901012r96.html
"List":
How to create: List () a=[' A ', ' B ', ' C ']
Method:
1, interception: a[head Subscript: Tail Subscript: Each step value] The default is: 1
2. Increase: A + a equals a*2
3. Merger: A + A
4. Append () method to add to trailer
5. Add the Insert () method to the specified location
6. Pop () Delete the last trailing element
7. Copy and replace by subscript l[1] = ' America '
Reference Address: http://www.jb51.net/article/76339.htm

' Set ': cannot contain duplicate elements
Creation method: Set () a={' A ', ' B ', ' C '}
Method:
1. Add and remove elements via add and remove
2. Merger: A + A
3. Add the update element after splitting
4. Get x for X in S
5, | and set
6. & Intersection
7.-Difference Set ^ symmetric difference set
Reference Address: http://blog.csdn.net/business122/article/details/7541486

"Tuple": tuple can only convert list to tuple, other types cannot be converted
How to create: Tuple () a= (' A ', ' B ', ' C ')
Method:
Interception: a[head Subscript: Tail Subscript: Per step value] The default is: 1
1. Increase: A + a equals a*2
2. Merger: A + A
3, Max (tuple): Returns the maximum value of an element in a tuple.
4, min (tuple): Returns the element minimum value in the tuple.
5, tuple (seq): Converts a list to a tuple.
6. CMP (Tuple1, Tuple2): Compares two tuple elements.
7. Len (tuple): Calculates the number of tuple elements.
Reference Address: http://www.jb51.net/article/47986.htm
"Dict": Dict () with a minimum of two parameters
Creation method: Dict (A=b,c=d) a={' a ': ' B ', ' C ': ' d '}
Method:
1, update a[' keyName '] = newvalue
2. Merger: D.update (D2) can merge D2 into D
3, add a[' keyName '] = newvalue
4. Get a[' keyName ']
5. Keys (). VALUES ()
6. Pop (' KeyName ') deletes the corresponding key-value pair according to key and returns the value
7, del dict[' Name ']; # Delete key is ' Name ' entry
Dict.clear (); # Empty Dictionary all entries
Del Dict; # Delete Dictionary
Reference Address: http://www.jb51.net/article/47990.htm

What are the variable types of

Python? and a summary of the variable types

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.