Python face question

Source: Internet
Author: User

1. Python Decorator

Details

2. Set up multiple Python projects using different versions of Python and third-party libraries

Using pyenv

Details

3, PEP8

Details

4. Parameter passing

Pass by reference

5. List parsing, dictionary parsing

Details

6. The difference between a list and a tuple

Once the tuple is assigned, the value can not be changed, the change will be error; The list can be changed arbitrarily.

7. Range () and xrange ()

(1) Range () returns the entire list

(2) Xrange () returns an Xrange object that can be iterated

(3) xrange takes up less memory space because xrange only generates the current object when looping

8. With statement

Details

9. Repeat the Import module or method

A module in Python does not load repeatedly

10. GIL

Global mutex under multi-threading ensures that only one thread in each process obtains the lock at the same time, accessing the relevant resources.

11. Special methods

(1) defined in some class

(2) Do not need to call directly

(3) Some functions or operators invoke the appropriate special method

12. Level Object

No usage restrictions.

The function itself is a level object.

13. class Foo and Class Foo (object)

The first one is the classic class, the latter one is the new class

Details

14. Extract every three items in the list

X is a list, and there are only two ways to do it.

defT1 (x): L=len (x) d= L//3R= L% 3 forIinchRange (d): N= 3 *IPrint('%d,%d,%d'% (X[n], X[n + 1], X[n + 2]))     forIinchRange (R): N= 3 *DPrint('%d,'% x[n + i])
def T2 (x):     = 0    for in  x:        print(' % i, end="        )= (n + 1)% 3        if not N:            Print ()

Python face question

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.