Chapter No. 02 Python Quick Start

Source: Internet
Author: User

007. Quick Start, learn by the side

008. Variable Type

Print (type (variable)) see the types of variables now commonly used types of variables are integer, float, character type

009. List Base Module

Type conversion: STR (8) converts 8 to a string of value the test character has no way to convert to a character type

010. List index 011, loop structure

Loop condition, in the for loop, called the loop body, the loop body indents 4 spaces or a TAB key

012. Judging structure:

The judging condition has two Boolean values, True and false, if it is true will execute if the content, otherwise do not execute

013, Dictionary module 014, file processing

1. File read, only need to specify two parameters, one is the name of the file, if the file in the current running directory, you do not need to specify the path, otherwise you need to specify the absolute path of the file, the second parameter is the operation of the file eg: "R" is the read operation of the file

The above code can read the contents of the file Test.txt directly f.read () read the contents of the file (read the current environment)

2. Write file operation, when there is this file, write the content in the file, if not, it will automatically create a "Text_write.txt file" and then write the content

3. This is a. csv file

Split () splits the file into lists, such as dividing the 1 sunny first by "\ n" and then following "," to slice

015. Function Basics

Define a function with the keyword DEF

With a colon, followed by indentation

function definitions can have parameters, or they can have no parameters

Chapter No. 02 Python Quick Start

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.