Basic Python Learning 1

Source: Internet
Author: User

1. Write Python code principles:

    • Uniform indentation, the same level indentation must be consistent, different levels must be more indented;

    • Shelf start writing, can not have spaces;

    • Variable

It is recommended that you write on the Windows-side installation Pychram program.

2. Variable Name requirements:

    • The first character of the identifier must be the letter in the alphabet (either uppercase or lowercase) or an underscore _

    • Other parts of the identifier name can consist of a letter (uppercase or lowercase), an underscore _, or a 0-9 number

    • Identifier names are case-sensitive

    • You cannot use commands in Python

3. How to define Python environment variables and encodings

    • The first line of the program declares, such as: #!/usr/bin/env python

    • declaration Code format U tf-8: #-*-Coding:utf-8-*-#这样可以免除中文乱码
      Such as:
      #!/usr/bin/env Pyhon
      #-*-Coding:utf-8-*-

4, how to comment:

    • Single-line comments start with a # number, like a shell, such as print ' Print Python test '

    • Multi-line comments

Such as:

info = "Print test1

Test2

Test3 ""

Print Info


This article is from the "Chhhsdbohe" blog, make sure to keep this source http://437972.blog.51cto.com/427972/1835467

Basic Python Learning 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.