Retake Course Day6 (collection of Python base 4 and file operations)

Source: Internet
Author: User

A dictionary attribute method complements

1 Clear: Empty

2 Cory: Copy

3 Fromkeys: Generate a dictionary, a property method below the class

4 Pop: Delete

5 Popitem: Delete entire element

6 SetDefault: Add only and do not modify

7 update: Existing words with new, no will add

Functions of two sets and collections

A collection is a value that does not exist and is unordered.

1 add: adding Impossible duplicates

2 clear: Empty

3 Copy: Copy

4 difference: There is only one set of differential sets

5 difference_update: Finding the difference set and updating

6 Symmetric_difference: Finding symmetrical difference sets

7 symmetric_difference_update: Symmetric difference Set and updated

8 Discard: Delete Based on object

9 Intersection: Intersection

Ten intersection_update: Intersection and update

Union: Unions

Isdisjoint: Judging if there is no intersection

Iscubset: Determine if it is a subset

Issuperset: Determine if the parent set

Random Pop deletion

Remove: Specify Delete

Update: Updated

Len: Length

Set in the general case, the collection property must precede the collection, the property can be placed after any data type, the value inside the collection is not to become. {} The default is a dictionary, which you want to create is set ()

Three-file operation

Common methods for files right

1,r (Read): Read files, can only read, no other operation; r+: Not only can read, but also can write, r+ is read before writing

2, W (write): Write to file, write only, w+: But can write, and can write and then read.

3, A (append): Append content, can only append; a +: You can also read files after appending

Properties operation under File:

1 read: Reading files

2 Write: Write to File

3 Seek: Adjust the position of the cursor

4 Tell: Where to read the cursor

5 Writable: Writable

6 Readable: readable

7 Close: Close file

8 Flush: Swipe to hard drive

9 Fileno: File Object

Isatty: Determine if the output device

ReadLine: Reading a line of content

Seekable: Determine if pointers can be set

Truncate: The content after the cursor is not, as long as the contents of the front of the cursor

ReadLines: Read all the contents and then a piece of supervisory memory

The xreadlines in Python2 is equivalent to the in-line-F in Python3:

Retake Course Day6 (collection of Python base 4 and file operations)

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.