Unified and well-designed code specifications, is a good programming habit.
Pycharm This Python IDE uses the famous PEP8 code specification, we will see that when there are code that does not conform to the specification, the compiler gives a hint
Topic
Given n non-negative integers representingthe histogram ' s bar height where the width of each bar are 1, find the area Oflar Gest rectangle in the histogram.
Above is a histogram where width of eachbar is 1, given height =
Python's queue is designed to be thread-safe , so be assured that the big guy is using it.A simple implementation of Python multithreading is as follows:
#!/usr/bin/env python
#-*-coding:utf-8-*-
Import Threading
Import time
def fun (argv):
Careful use of variable length parametersPython supports variable-length parameter lists, which can be implemented by *arg, **kwargs these two special syntaxes. The following examples are used for variable length parameters:* Use *args to implement
background
Some of our formal code is written in Python, and this part of the code needs TDD, so we need to find a useful test framework. Framework Selection
Python's Test Tools
The first types of files that are generally used in Python are as follows:
1. Write to File
#这种写入方式会将原文本删除, re-write
File = open ("Test.txt", ' W ')
2. Reading file read
3. Add write Add
#这种写入是在原文件的基础上, continue writing
File
------------------------Data Structure------------------------
If you've ever had programming experience, then you probably know what a data structure is.
The data structure is the way in which it is organized. In Python, the simplest data structure
8–2. Cycle.
Write a program that allows the user to enter three digits: (f) ROM, (t) O, and (i) ncrement. Take I as step, from F to T, including F and T. For example, if you enter F = 2, t = =, I = 4, the program will output 2, 6, 10, 14, 18, 22, 26.
implements the int sqrt (int x) function.
Calculates and returns the square root of X, where x is a nonnegative integer.
Because the return type is an integer, the result retains only the part of the integer, and the decimal part is given
If you already have some programming experience, the quickest way to learn a new language is to hold a medium-sized project, to get to know the project again, to read the grammar of the new language, AHA, personal opinion
Today to formally configure
Python date, character interchange
Date Spin string
1. Read data from Excel, in Excel date this column data format type is "Short Date"
Test = Pd.read_excel (' f:/test.xlsx ')
Test.head (2)
2. View data types for read data
test[' Date '].apply
Recently used PIL to do simple site image processing, but there are always some problems, fortunately stackoverflow on the cattle too much, search also has the answer. 1.jpg Picture stored as progressive error
The web often has to turn pictures into
Functions and Procedures
Most languages will have the following definitions:
Function: Has return value
Process (Procedure): A special function that is simply special and has no return value
Only functions in Python have no procedures.
The
Let's introduce two functions:
One. Os.walk () can get a ternary tupple (Dirpath,sub_dirs, filenames), where the first is the starting path, the second is the folder under the starting path, and the third is the file under the starting path.Where
If you did much work on computers, eventually your find this there ' s some task you ' d like to automate. For example, if wish to perform a search-and-replace over a large number of text files, or rename and rearrange a bun Ch of photo files in a
about blocking the main thread
error usage for join
Thread.Join () acts as a blocking main thread, that is, when the child thread is not returned, the main thread waits for it to return and then continues execution.
Join cannot be used with start
Turtle ModuleTurtle Drawing (Turtle graphics), Python built-in module, a very simple and fun library.First, guide the storageImport Turtle from Import *Second, the canvas settings" " Set Brush size " " turtle.screensize () # returns the
Crawling with embarrassing contentGitHub Code Address https://github.com/injetlee/Python/blob/master/qiubai_crawer.pyPublic number: "Smart manufacturing column", welcome attention.Objective of this article
Mastering the basic concepts of
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