The Python version on the server is too old to install a new Python version in order to run my code. Because of the needs of the environment, but can not uninstall the old version, so install a new, use the soft chain to upgrade. Using the system
First seen in handwritten, similar to the following: 1 import datetime 2 3 def time_1 (): 4 begin = Datetime.datetime.now () 5 sum = 0 6 for I In Xrange (10000000): 7 sum = sum + i 8 end = Datetime.datetime.now () 9
1.string.maketrans Set string conversion rules table (translation table)
Copy CodeThe code is as follows:
Allchars = String.maketrans (', ') #所有的字符串, that is, do not replace the string
Atob = String.maketrans (' A ', ' B ')
Examples can be downloaded in attachments
1. Loading an XML file
There are 2 ways to load an XML file, one to load the specified string, and two to load the specified file
2. How to obtain the element
A) through Getiterator
b) Over GetChildren
C)
I want a large group of classes have a characteristic, how can I add to them? Template template, I create a bunch of classes from this template is not OK? That would require a meta-class. Rattling
Define a meta-class (a template for one class!) Mo
For example, when learning list, tuple, dict, str, OS, SYS and other modules, the use of Python's own documentation can be a very quick and comprehensive learning of those processing functions. Therefore, this self-documenting function can provide a
1 Installing the Configuration development environment
1.1 Preparing for installation
Download the following software
Eclipse for C + +
SUN JDK 1.6 doesn't have to be 1.6,1.5.
Python3.1 Python2.6.4 Pythone2.5.2
mod_python-3.3.1.win32-py2.5-apache2.2
The following is the final code (implemented under Windows)
Copy the Code code as follows:
#-*-coding:cp936-*-Import OSPath = ' d:\\ picture \ \ 'For file in Os.listdir (path):If Os.path.isfile (Os.path.join (path,file)) ==true:If File.find ('. ')
1) Use of regular expressions.
Copy CodeThe code is as follows:
#正则表达式的模块
Import re
#正则表达式
Repattern = '. *[0-9]{4} '
Pattern = Re.compile (Repattern)
#匹配
If Pattern.match (line):
Return True
Else
Return False
2) Use global variables in the
The QR Code recognition program on the phone has done very well, "I check" with very good
I have collected several two-dimensional barcode generation sites:
http://www.morovia.com/free-online-barcode-generator/qrcode-maker.php
1. Python multi-process programming background
The greatest benefit of many processes in Python is to make full use of the resources of multicore CPUs, unlike Python's multi-threading, which is constrained by the Gil's limitations, and thus can
Theme:
Why should there be a way?
The answer is: laziness is a virtue
Definition of method Keywords:
Def
Use callable to determine if it is callable:
Copy CodeThe code is as follows:
x = 1
y = math.sqrt
Callable (x) #False
Callable (y) #True
Python makes it easy to support multithreading. You can quickly create threads, mutexes, semaphores, and so on, enabling threads to read and write synchronous mutexes. In the ointment, Python runs on a python virtual machine, creating multithreading
1. The GetAttr () function is the core function of Python introspection, which is used in the following general context:
Class A: def __init__ (self): self.name = ' zhangjing ' #self. Age= ' Def method (self): print "Method print" Instance = A (
Test system Environment Windows 2003 python 2.5.1 MySQL 5.0.1
Should only apply to win because CMD is called.
Incremental backup, because for personal use, the database is small.
Back with the need to add self-detection, 5 days ago automatic
Flask Source Code Reading Notes (1), flask Source Code Reading NotesAuthor: acezioLink: https://zhuanlan.zhihu.com/p/21358368Source: zhihuCopyright belongs to the author. For commercial reprint, please contact the author for authorization. For
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