The path to Python in Xiao Bai _ day1 and the path to python _ day1

Source: Internet
Author: User

The path to Python in Xiao Bai _ day1 and the path to python _ day1

  • Comparing Python with java, the code is more concise.

Python 3.X Hello World Program:

    print("Hello World!")

Java Hello World Program:

    public class HelloWorld{       public static void main(String args[]){         System.out.println("Hello World!");       }    }
  • Python requires no additional points after each sentence of code.
  • The annotation Syntax of Python is different from that of java. A single line annotation is a single line annotation # the content to be annotated

     Comment on multiple rows using three single quotes or three double quotes ''' comment content '''

  • Python variables can be named by underline or camper. However, we recommend that you use underline to name variables. For example, student_number
  • When defining a Python variable, you do not need to specify the data type, but you must clearly understand the type of each variable when running the program.

    

It can be seen that a is an integer, and B is a string because it is an input string. Even if it is both 10, the data type is different.

  • Python also supports forced type conversion. The format is: type (variable) to be converted)
  • In Python, we recommend that you use indentation instead of curly braces. We recommend that you use four spaces instead of tabs for indentation. Therefore, when using Notepad ++ to write Python code, you can choose Settings> preference> language> tab settings and select "Replace the tab width with a space ". As shown in:

    

  • Python 2.X is encoded in ASCII by default, and ASCII does not support Chinese decoding. Therefore, you must add
    #!-*- coding:utf-8 -*- 

    Or

    #coding:utf-8

    To replace the encoding table. [Note: The supported Chinese encoding tables include GB2312 (6763 Chinese characters), GBK 1.0 (21003 Chinese characters), GB 18030 (27000 + Chinese characters), and Unicode universal code table]

  • Python 3.X is encoded as Unicode by default. Therefore, it supports Chinese characters by default.

End

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.