Python Basics-ongoing updates

Source: Internet
Author: User

1. Module Import

Import xxx or from xxx import xxx, try to avoid using from XXX import *

2. Variables, constants

Local variables: can only be used within a function or within a class to assign values and change values

Global variables: Can be used in all functions or classes to assign values and change values

Constants: Determined values, cannot be assigned and change values

3. Data type

Integer: If 2

Floating point number: if 2.2

String: "abc"

Boolean value: True/false

List: [2,3,4]

Dictionary (dict): {"name": "Jack", "Age": "30"}

Null value: None

4. Process Control

If

For

While

Break: Jumps out of the current loop and exits the loop

Continue: Jump out of the current loop and proceed to the next loop

5. File reading and writing

Excel read-write module: XLRT, XLWT

XML read-write module:

6. Error handling

Try

Except

7. DateTime, TIME

DateTime formatting

String converted to DateTime

DateTime Conversion to String

8. Request

Python Basics-ongoing updates

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.