1. Construct and initialize objects
__init__The method is Python's built-in magic methods (what is the magic method ?) The most common one is that we can use this method to define the initial operations of an object. When a constructor is called,
Before the start of school, I took a task to crawl data with specific attributes from the Internet. I learned python and practiced it before.Encoding Problems
Because it involves Chinese characters, it is inevitable that the encoding problem is
1. Copy the following code to a file named asyncore. py.
Ds_asyncore (addr, callback, timeout = 5 === s. recv (1024 1
2. Write your own code
1> Import asyncore
2> define the callback function callback. callback requires a parameter that
The following is a simulated operation to maximize the browser control.
When we use image and coordinate-based auxiliary testing tools in the test, we need to maximize the browser's storage during each test, this allows you to compare images
The following uses WebDriver to promise the title and address of the browser page.
In the test, it is very common to visit a page and determine whether the title meets expectations:
Assume that the title of a page should be 'Hello
The following uses webdriver to control the size of the browser window.
Setting the size of a browser window has the following two common purposes:
Running use cases in a unified browser size can be easily combined with some image-based
The operations on form objects are relatively simple. You only need to remember the following points:
Use the send_keys method to assign values to the multi-row text box and single-row text box;
Use the click method to select checkbox
Use the
I am confused when I look at the source code of Form related to Django (1.6). So I excerpted several code snippets in django. forms. py to analyze how to use the Meta class in Django:
with_metaclass(meta, * meta( ( %
There are many ways to connect to MYSQL in python 3.2, such as using mysqldb and pymysql. This document describes how to connect to MYSQL using Pymysql.1. Install pymysql
· Ensure that python3.2 is correctly installed
· Download installation
Example 1. determines whether all strings are lowercase letters. find out the full spelling of acronyms in a sentence. remove the comma (for example, 123,345,000) in the number from the syntax regular character interpretation example + the previous
Copy codeThe Code is as follows:# Set a as a stringImport timeA = "10:00:00"
# In the intermediate process, strings must be converted to time arrays.Time. strptime (a, '% Y-% m-% d % H: % M: % s ')> Time. struct_time (tm_year = 2011, tm_mon = 9, tm_
Preparations
Development Environment: python2.6, reportlab
Prepare a Chinese font file: simsun. ttc
Code:
Copy codeThe Code is as follows:#! /Usr/bin/env python2.6# Coding: UTF-8
Import traceback
From reportlab. graphics. shapes import DrawingFrom
Install the corresponding library. I use PyV8.
Note that the function written in it must be enclosed ().
Copy codeThe Code is as follows:Import PyV8
Class Test ():
Def js (self ):
Ctxt = PyV8.JSContext ()
Ctxt. enter ()
Func = ctxt. eval ('''
Gravatar registration address: https://en.gravatar.com/
Copy codeThe Code is as follows:"'Gravatar '_"""
# Import code for encoding urls and generating md5 hashesImport urllib2, hashlib
# Make response slow if verify whether default avatar or not.#
Copy codeThe Code is as follows:#-*-Coding: UTF-8 -*-
Class Heap (object ):
@ ClassmethodDef parent (cls, I ):"Parent subscripts """Return int (I-1)> 1 );
@ ClassmethodDef left (cls, I ):"Left son subscript """Return (I
@ ClassmethodDef right (cls,
Python algorithm learning-counting sorting instance
Copy codeThe Code is as follows:#-*-Coding: UTF-8 -*-
Def _ counting_sort (A, B, k ):"Counts are sorted. The pseudo code is as follows:COUNTING-SORT (A, B, k)1 for I defaults 0 to k // initialize
The main functions are implemented in the copyFiles () function as follows:
Copy codeThe Code is as follows:Def copyFiles (src, dst ):SrcFiles = OS. listdir (src)DstFiles = dict (map (lambda x: [x, ''], OS. listdir (dst )))FilesCopiedNum = 0# Copy
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