Python Basics 0-4

Source: Internet
Author: User

Collection

He's working on the dictionary. The collection of tuples is a counter

No matter the depth, the shallow, the assignment copy memory address is unchanged

Assignment is also a copy of the


Two types of copies
Numeric string

Another category:

List Dictionary tuples

This class is divided into two layers.

:
The memory address is not changed when the value is assigned
:
But the memory address changes when the shades are copied.

:
Saves memory space, regardless of whether a deep copy eventually points to a referenced value
:
Even if the deep copy, his address changed.
:
But all he's changed is a quoted address.
:
The specific value is also a

:
He just copied a copy of the quote.
:
Do you know what a reference to a list dictionary tuple is?
:
It's their index.
:
Index

0-256 number has a pool, so every time to take data do not have to open up memory, go directly to the pool to fetch, very fast!

Default Dictionary exercises:

From collectionsImport Defaultdict #导入模块
values=[11,12,13,18,30,50,80,100,85,90, 91,92,95]
dict= Defaultdict (list) #设置成默认列表
for Value in values:
66:

Dict[ ' K1 ']. Append (value) #只有列表才有append方法

else:

Dict[ K2 '].append (value)

print (dict)

Python Basics 0-4

Related Article

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.