There are several ways to debug with PDB
The main way to debug Python programs with PDB is the following three kinds! The following describes
Command line plus-m parameter
The command line launches the target program, plus the-m argument, so that
Python currently offers several multi-threaded implementations, where the thread module is thread,threading,multithreading, while the threading module is a wrapper for thread and can be used more conveniently.
Prior to version 2.7, Python support
Method One
If you do not use cookies, sending an HTTP POST is very simple:
The code is as follows
Copy Code
Import Urllib2, Urllibdata = {' name ': ' www ', ' password ': ' 123456 '}f = Urllib2.urlopen (url = '
1. Format of date output
All date and time APIs are within the DateTime module.
1. DateTime => String
1 now = Datetime.datetime.now ()
2 Now.strftime ('%y-%m-%d%h:%m:%s ')Output 2012-03-05 16:26:23.870105
Strftime is an instance method of a
Use for statementExample 6.3 uses a for statement
The code is as follows
Copy Code
#!/usr/bin/python# Filename:for.pyFor I in range (1, 5):Print IElseprint ' For loop are over 'Output$ python for.py1234The For loop are
The problem this time is still related to Python Unicode. Take a look at the following code:
The code is as follows
Copy Code
[~/tmp]$ Cat test.py#coding: UTF8Foo = u ' Test 'Print Foo[~/tmp]$ python test.pyTest[~/tmp]$
This time this really is dry goods oh, last night made a half night,,,, from 8 points after eating dinner began to write, has been nearly 12 o'clock to finish,,, novice, can't afford to hurt Ah ....First of all, Baidu provides a music search API,
Demand:
To handle a configuration file, take out the available character stitching, the following is the original text, we want to get this result,
Redis-h 127.0.0.1-p 6379 | Select 2Redis-h 127.0.0.1-p 6379 | Select 16Redis-h 127.0.0.1-p 6379 |
Example
Write yourself a python traversal file script, to the file to be identified for specific processing. There's no technical content, but record it.
The code is as follows
Copy Code
#!/usr/bin/python#-*-Coding:utf-
The code is as follows
Copy Code
#!/usr/bin/python#-*-coding:cp936-*-Import OSImport ZipFile def unzip (Infile,targetdir):If not os.path.exists (infile):Return FalseIf not Os.path.isdir (TargetDir):Os.makedirs (TargetDir)TryZipobj =
Python's level is currently in the active phase, usually written scripts used by the Python writing is also relatively simple, did not write a slightly larger project. There is a lack of understanding of how classes in Python are being coupled
Sometimes in the context of a process, locale is set to support only ASCII character sets (such as Lang=c). At this point Python will set the standard output and standard error encoding to ASCII, resulting in the output of the Chinese times wrong.
Today, when the server is debugging some software, it needs to have a Python version. So I have this article.
The steps are more detailed. Installation is also relatively simple. The main thing is to set the variable.
Download
LRU (Least Recently Used) has not been Used for the longest timeIn computing, cache algorithms (also frequently called cache replacement algorithms or cache replacement policies) are optimizing instructions-or algorithms-that a computer program or a
Installation stepsCheck the current Python versionPython-VInstall GCC compiler in yunYum-y install gccDownload/decompress the Python-2.7.2 installation package# Foreign VPSWget-O Python-2.7.2.tar.bz2 https://www.dropbox.com/s/7ia7obzbsagl3zb/Python-2
Operations on files and folders (File operation functions) in python involve the OS module and the shutil module.Get the current working directory, that is, the directory path for the current Python script: OS. getcwd ()Returns all files and
There are several methods:1. Add the environment variable PYTHONPATH. python will add modules under this path and add the following lines in the. bashrc file:Export PYTHONPATH = $ PYTHONPATH:/usr/local/lib/python2.7/site-packages2. Add a path
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