Concise Python Tutorial Learn note 1

Source: Internet
Author: User
Tags acos mathematical functions natural string

1. Introduction

Slightly

2. Install Python

Slightly

3. Initial steps

(1) Get help ()

    • Help () use
1>>> Help (" Help")2 3Welcome to Python 2.7! This isThe online Help utility.4 5If this isyour first time using Python, you should definitely check out6The tutorial on the Internet at http://docs.python.org/2.7/tutorial/.7 8Enter the name of any module, keyword,ortopic to get help on writing9Python Programs andUsing Python modules. To quit this help utility andTen returnTo the interpreter, just type"quit". One  ATo get a list of available modules, keywords,orTopics, type"Modules", - "keywords",or "Topics". Each module also comes with a one-Line Summary - of what it does, to list the modules whose summaries contain a given word thesuch as"spam", type"modules spam". -  ->>> ->>>
Help's use
    • Help () Get assistance with the module
1>>> Help ("Math")2Help on built-inchModule Math:3 4 NAME5 Math6 7 FILE8(built-inch)9 Ten DESCRIPTION OneThis module isAlways available. It provides access to the A mathematical functions defined by the C standard. -  - FUNCTIONS the ACOs (...) - ACOs (x) -         
help getting the module
    • Help () Get assistance for a class
1 >>> Help ("str")2classin__ builtin__:34class  str (basestring)5  |  STR (object="), string6  |  7  |  Return a nice string representation of the object.
Help getting Classes
    • Help () How to get methods
1>>> Help ("Str.split")2Help on Method_descriptorinchStr:3 4Str.split =Split (...)5S.split ([Sep [, Maxsplit]])List of strings6     7Return A list of the wordsinchthe string S, using Sep as the8Delimiter string. If Maxsplit isgiven, at the most maxsplit9Splits is done. If Sep is  notSpecifiedor  isNone, anyTenwhitespace string isA separator andempty strings is removed One      fromThe result. A  ->>>
help How to get methods
    • Conclusion

If you need to get help information such as a module, class, or method, you can use the helper method, which is a string representation of the corresponding module, class, or method.

4. Basic Concepts

(1) Constants

Slightly

(2) Number

Slightly

(3) string

    • Single quote: ' This is String '
    • Double quotation marks: "This is a string"
    • Three quotation marks: "This is a string" or "" "This is a string" "
    • Escape
1>>>#\ ' escaped as '2>>>Print 'what\ ' s your name'3What's your name4>>>#\ nthe escape for line break5>>>Print 'First Line\nsecond line'6  First Line7 Second Line8>>>9>>>
escaped
    • Natural string

If you want to indicate certain strings that do not require special handling such as escape characters, you need to specify a natural string.

Natural strings are specified by prefixing r or specifying the string R .

1>>>#\ nthe escape for line break2>>>Print 'First Line\nsecond line'3  First Line4 Second Line5>>>#\ nthe escape is not performed6>>>PrintR'First Line\nsecond line'7 First Line\nsecond line8>>>
Natural String
    • Unicode string

When processing a string that contains non-English characters, use a Unicode string and precede the string with U

1 >>> str1 = u'Unicode String'2print  type (STR1)  3'Unicode'>4print  str15 Unicode String
Unicode string
    • The string is immutable

(4) Variables

Slightly

(5) Naming of identifiers

Slightly

(6) Data type

Slightly

(7) Object

Slightly

(8) Logical lines and physical lines

Physical line: A line that can be seen when programming

Logical line: A single statement that Python sees

(9) Indent

Slightly

Concise Python Tutorial Learn note 1

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.