Beginner python, the small edge of a few questions:
There is a list
A = [1, 2, 3, 4, 5, 6]
Please use a according to
0, 1
1, 2
2, 3
3, 4
4, 5
5, 6
Print output,
2. Reverse a list to [6, 5, 4, 3, 2, 1]
3. Select the even number in a and the result is
Open the DOS window directly before executing the Python program
After the last line of the script, add the following: Raw_input () statement so that the window is closed until the ENTER key is pressed.
Using the time module's sleep function, it has
So I want to turn these pictures over, but the pictures of the phone
is automatically divided by the time folder, a folder copy is very troublesome, so I intend to write a small Python script to complete the work (pull so much, finally
To the
Continue list:
To delete an element:
The code is as follows:
A =[1, 2, 3, 4]A[2:3] = [] #[1, 2, 4]Del a[2] #[1, 2]
Clear List
The code is as follows:
a[:] = []Del a[:]
The list is used as a stack (after-in first-out):
The code is as
First of all, to look at the case of a character each time, you can have the following methods to achieve:
Method One:
The code is as follows:
>>> a= ' 1234567 '>>> List (a)[' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ']>>>
Method Two:
The code
The code is as follows:
Import OSImport SysImport FtplibImport socket
################################################################### Sign in the FTP server and download the log file.# Log in to production server download logs###################
1. XLRD (especially read operations) is recommended for simple read and write operations in Excel in Python
2. Go to http://pypi.python.org/pypi/xlrd to download the XLRD library;
3. The project code is as follows:
The code is as follows:
In Python, a set of naming systems is adopted to identify the access scope of the
Class Myobjec (object):
Username = "Developerworks" # Public
_email = "Developerworks#163#.com" #protected
__tel = "1391119****" # Private
Some clever naming methods
For example, to convert a string object s from GBK inside code to UTF-8, you can do the following
S.decode (' GBK '). Encode (' utf-8′)
However, in real-world development, I found that this approach often occurs abnormally:
Unicodedecodeerror: ' GBK
The code is as follows:
#-*-Coding:utf-8-*-From win32com.client import DispatchImport timedef start_office_application (app_name):# after getting to the app here, the rest of the operation is similar to operating the Office software through VBAApp
Function prototypes
Declaration: S is a string, RM is a sequence of characters to be deleted
S.strip (RM) Remove the characters from the beginning and end of the s string in the RM delete sequence
S.lstrip (RM) Delete the character in the S
The code is as follows:
#-*-Coding:utf-8-*-Import threadingImport timedef fun (name, ls_name, Front_thread = None):'''''Thread Start functionUsing thread-ordered runs through Front_thread'''Time.clock ()Time.sleep (2)# If Front_thread exists, the
The code is as follows:
#Filename: brn.py#Description: Batch Replace certain words in file names#Use to bat Rename the file in a dir (modify the suffix from A to B) for Windows Vista OSImport SysImport OSImport FnmatchImport re#parse paramsP=input (
This bo can be said even the opening line can be omitted, the reason is DDoS, not because of the mad dog was chased to bite, but because of the VC tragedy after the flow of all to SIMPLECD came.
Not only that, some idiots are grasping the station,
Python file:
The code is as follows:
#parsexml. py#本例子参考自python联机文档, made the appropriate changes and addedImport Xml.parsers.expat#控制打印缩进Level = 0#获取某节点名称及属性值集合def start_element (name, attrs):Global levelprint ' *level, ' Start element: ', name,
Word is good for English words, so let's try it. If you don't have Word installed, and you're a program clerk, you can use my code. Through the test, Word's statistical results are 18674, the software statistical results are 18349, the difference is
For compatibility, you can only select compatible: Colon.
Very simple, modify the Cookie.morsel
The code is as follows:
#!/usr/bin/python#-*-Coding:utf-8-*-"" "Morselhook, fix Cookie.CookieError:Illegal key value:ys-tab:entrance:e"""Import
First run the Easy_install Pymongo command to install the Pymongo driver. Then do the following:
Create a connection
The code is as follows:
In [1]: Import PymongoIn [2]: Connection = Pymongo. Connection (' localhost ', 27017)
Switch to database
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