Python Learning notes Section 12th

Source: Internet
Author: User

Module:
A module is essentially a py file.
Divided into three parts: built-in modules, third-party modules (module calls and package concepts)
Find the py file in the interpreter first, then find the file under the installation path Lib, and then find the custom module.
Time stamp:
1970 set a time of 0, time each additional second after +1
So each time can be represented by the following numbers

Print (Time.time ()) to get the current timestamp
Time.localtime Structured time

Greenwich Mean Time:


To convert a timestamp to a structured time:

To convert a structured time to a timestamp:

To convert a structured time to a string time:

Convert string time to structured time:

Another kind

Change string time

Random module

Random display of a number
Random.random floating Point
Random.randint integer


Randomly displays one of the following three parameters

Various uses
Sample followed by a list, write a parameter in the back
Randomly select the number of arguments in the list.

Shuffle randomly, change the order of the list randomly

Convert numbers to letters by function
and convert the letters into numbers

Random display of 5 letters + digits + Capital letters verification Code

Hashlib, MD5
MD5 (32-bit)
Update can be constantly update
The hexdigest in the back can add the above cumulative


Website Storage account password Do MD5 can be added salt processing, in order to avoid the account password is hit library

Add salt to admin

OS Module
Two things: Work down the hardware and provide an interface up.


Show current directory Address

GETCWD changes the current directory address, which changes the address where the directory was created.
R native String, do not translate

Displays all file contents under the path and is born into a list

The file cannot be opened by operation when renaming.

Displays file information, RET is an object that can be added. St_mtime and so on.
St_ctime creation Time St_mtime Modify time St-atime access time st_size size (bytes)


The Os.path.split path and file name are saved separately as a single tuple.

Take DirName or basename alone

Python Learning notes Section 12th

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.