A single module test, relatively simple, simply introduces UnitTest, creates your own test class, inherits Unittest.testcase, and executes Unittest.main () to automatically execute all test code that starts with test. You can use assertions similar
Import string
import os
import struct
import re
import fileinput
import Fnmatch
Fileinput and Fnmatch Two module are mainly used here
Fnmatch.fnmatch is primarily used to determine the suffix name of a file
Fnmatch. Fnmatch (filename, pattern) for
#-*-coding:utf-8-*-Import functools import types ' Write a decorator that can print a log of ' Begin call ' and ' end called ' before and after the function calls. ' #这个不难 def logt (text): Def log (func): @functools. Wraps (func) def wrapper (*args,*
I've always written some Python command-line gadgets to simplify some repetitive work in my work. There is a need to traverse the case of a directory, the original has been written in a recursive procedure to do this thing, the first two days before
Original address: http://agiliq.com/blog/2013/09/understanding-threads-in-python/, http://my.oschina.net/leejun2005/blog/179265
----------------
Catalog [-] Example 1, we are going to request five different url:1, single-threaded 2,
Each module in Python has a name, and when a module is first entered, the module's main block (__MAIN__) is run. What do we do if we just want to run the main block when the program itself is used, and not run the main block when it is entered by
It is more efficient to compile these expressions for expressions that are frequently used by programs. The compile () function converts an expression string into a regexobject.
The following example is derived from the Python standard library:
Method 1:
Import datetime
def main ():
begin = Datetime.date (2014,6,1) End
= Datetime.date (2014,6,7)
for I in range ((End-begin). days+1): Day
= begin + Datetime.timedelta (days=i)
print str (day)
if __name__ = = ' __main__ ':
Main ()
http://cage.8cuo.org/?p=115Python's parameter types can be grouped into 4 categories: 1. Position parameters 2. keyword parameter 3. Tuple parameters 4. Dictionary parametersFirst, Position parameters:Features: Unlimited number of calls must provide
Show user inputuser = Raw_input (' Enter first Name: ')//raw_input is a built-in function====> Enter first Name: rootprint ' name is: ', User===>name is:root
int () string to digitnum = Raw_input (')1024print '%d '% (int (num) *2)2048
#为注释
Symbol: +,
Recently in learning Python,python can be said to write some small script of the sharp weapon syntax simple, as the most famous in the "glue language" to write some command script is very convenient.
Today I want to use Python to execute the ADB's
More traditional, is the use of the OS module,
deleting files
Os.remove ()
Delete Empty Directory
Os.rmdir ()
Recursively Delete parent Directory
Os.removedirs () #当子目录为空, recursively deletes the given parent directory, or throws an exception
Method One: print u ' positive '
method two: join
Import sys
reload (SYS)
sys.setdefaultencoding (' utf-8 ')
solution at this point is to tell Python how to encode it, telling it to be in the initial part of the source file, the top line
information that needs to be crawled
URL: http://bj.xiaozhu.com/Crawl information:Crawl 300 listings on the page, including title, address, daily rent, the first listing pictures link, landlord picture link, landlord sex, landlord nameCode
From BS4
The use of Numpy,python can be used for effective scientific calculation. This article to the past commonly used MATLAB, is now learning numpy people.
Do you use array or matrix when you are working with matrices?
Short answer, more time using array.
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