C # programmers are new to Python,

Source: Internet
Author: User

C # programmers are new to Python,

During the internship phase, I am idle every day. Today I read Python for a day. I have heard that python is as simple as reading English, and I have seen python on google's recruitment information before. Today, compared with C #, C, java, and vb, python is indeed very simple.

So it takes half an hour to summarize the conciseness of python.

1. If a python statement is correctly written, a semicolon is not required for each line;

2. python does not contain braces. The number of spaces is used to determine the statement hierarchy. This forces spaces to increase the readability of the statement;

3. python variables do not need to be declared, nor are data types defined. You can use them with values, which is very convenient;

4. the python string type can be referenced in single quotes and double quotes. Each character is unique. You can also use three quotes. Three quotes can reference multiple lines of strings, and special characters in the middle of the three quotes do not need to be escaped;

5. Add the r or R character before the string. The Escape Character of the string should not be used;

6. Once a string is created, it cannot be changed;

7. There is no separate char type in python;

8. If the line of code is long and needs to be written in two lines, you can use \ as the connector at the end of the first line. Do not use semicolons for both lines;

9. There is no switch... case... statement in python. It can be replaced by if... elif;

10. The while statement is followed by an else command to execute the loop;

11. for loops are only in the simple for I in range () format;

12. The number of rows is defined by def;

13. function parameters include "default parameter values" and "Key Parameters" to facilitate personalized function operations;

14. All self-written python files can be used as a module and called in other programs;

15. The list definition and operations in python are very simple. The format is shoplist = ['A', 'B', 'C'].

16. You can use a dictionary to process key-value pairs in python. The definition operation is also simple;

17. All methods in a class must have the self parameter, which is equivalent to this in C # and java;

18. The _ int _ function in class is used for initialization when an object is created, which is equivalent to the constructor in C # and java;

19. The _ del _ function in the class is executed when the object disappears;

20. All the members in the class are public and the methods are valid. If you want the method to be private, start with a double underline;

21. When inheriting the parent class, you only need to write the parent class name in the brackets behind the class name;

Let's write so much. It's almost time to get off work. If there are errors in those areas, please give me some advice...

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.