The Zen of Python, by Tim PetersBeautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases
Original link: http://blog.guoyb.com/2016/12/03/bad-py-style/Recently looking at some old aging systems, some of which have bad code habits left out of the pit, plus recently wrote a piece of bad code caused the server load soared, so take this
The best solution to the problem is to find the code that someone else has to solve a similar problem. Today, do some small exercises that can look back at what you have learned, and similar questions refer to someone else's code and modify it to be
// __new__ (cls[,....]) // object instantiates the first method of the call, its first argument is this class, and the other parameters are passed directly to the __init__ () method // overriding the __new__ () method when you need to modify it on
1. Install PythonDownload the response System version to the official website (for example, Windows here): https://www.python.org/downloads/windows/And then there's the "Next Step",2. RunningTo be able to run at the command line like node, first
KISS is kingly!KISS = = Keep It simple,stupidNo matter what, stick to the simple process/principle/structure/code, is comfortable!Now small white want to use multi-threading to improve the speed of queries, using threading module!# -*- coding: utf-8
Python Basics-Basics1. The first python-suffix name can be arbitrary?-When importing a module, if it is not a. py file==> after the file suffix name is. py2. Two modes of executionPython interpreter py file pathPython enters the
Concatenation of stringsa = "hello"b = "klvchen"c = a + bprint(c)结果:helloklvchenNote: This method is less efficient, and it is recommended to use the Join methoda = "hello"b = "klvchen"c = " ".join([a, b])print(c)结果:hello klvchenVarious methods of
Author:uljfangbr/>e-mail:[email protected]time:2018-3-25Requirements:1. User input related information2. Print out the following format:----------Info:name----------NAME:Age:JOB:SALARY:#! usr/bin/env
The basic method of a list of Python, which goes on to say dict,tuple.One, tuple, tuple1, the definition of the tupleOr:2. Use slices to access elements in tuplesDetailed reference to the slice usage of list3, the tuple is not modifiable, is
Import JSONdata={ "No": 1, "Name": "Runoob", "url": "Http://www.runoob.com"}The Json_str=json.dumps (data) # json.dumps () function encodes the data and converts it into JSON-formatted dataPrint ("Python raw Data:", repr (data))Print ("
1. Containers, iterative objects, iterators, generator concepts1. Container: A data structure that stores many elements. Usually stored in memory (iterators, generators are special cases) can use in to determine whether an element exists in the
Author:uljfangbr/>e-mail:[email protected]Time:2018-3-24message="Hello , Python World!"print("message")message="Hello, Python World! This language is Cool to learn well."print("message")RunHello, Python world!Hello, Python world! This language are
Problem solving
0. Print less than 10 even: bit operationfor i in range(10): if not i & 0x01: print(i)1. Given a positive integer that does not exceed 5 bits, it is judged by a few (using the Input function) method one: normal
Often in the process of installing software with PIP installation, then I always feel that Pip is for Linux and Mac, so I never studied Pip carefully, and then used Python to know that Pip is so useful
Summarize the usage of PIP today
My
Python Job 1: python job
1. Use the while LOOP input (numbers from 1 to 10) to print 1 2 3 4 5 6 8 9 10
Running result:
2. Calculate the sum of all numbers from 1
Running result:
3. Output all the even numbers in 1-100
Running
Python: Class, pythonclass
Like JavaScript, Python is a process-oriented language, an object-oriented language, and a dynamic language. In most object-oriented languages, Class is essential. Object-oriented has three main features: encapsulation,
Python json module and pythonjson Module
Import jsonData = {"No": 1,"Name": "Runoob ","Url": "http://www.runoob.com"}Json_str = json. dumps (data) # The json. dumps () function encodes the data and converts it into json-formatted data.Print
For the list sorting method with the element as the dictionary, sort the element dictionary list
Existing list such
List_to_be_sorted = [{'lv': 44, 'age': 10 },{'Lv': 12, 'age': 39 },{'Lv': 88, 'age': 22 },{'Lv': 6, 'age': 2 },{'Lv': 3, 'age':
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