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
Theory does not say much:
The code is as follows:
#!/usr/bin/pythonImport Sysdef merge (array, q, p, r):Left_array = array[q:p+1]Right_array = array[p+1:r+1]Left_array_num = Len (left_array)Right_array_num = Len (right_array)I, J, k= [0, 0,
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###################
The code is as follows:
A = 3b = A
First (Figure 1), you can see at a glance:
Variable name and object, after running assignment statement B = A, the variable A, a, is pointing to the memory space of object 3.Assuming that a = ' python ' is
>>> A = 2.5
>>> B = 2.5
>>> C = b
>>> A is C
False
>>> A = 2
>>> B = 2
>>> C = b
>>> A is C
True
When using the IS function to print a, B, respectively, is assigned a value of 2.5 and 2, found that:>>> A = 2>>> B = 2>>> ID (a)21132060>>> ID (b)2113
Installation method
1), Apt-ge installation
The code is as follows:
sudo apt-get install Flask-sqlalchemy
2), download the installation package for installation
The code is as follows:
# can be used directly in the PY after installationImport
The code is as follows:
#-*-Coding:utf-8-*-# Test various sorting algorithms# link:www.bitsCN.com# DATE:2013/2/2
#选择排序def select_sort (Sort_array):For I, Elem in Enumerate (Sort_array):For J, Elem in Enumerate (sort_array[i:]):If sort_array[i] >
There are defined fonts in the large frame of the website, including font size and color, which may be copied from other websites when the user publishes the article, and the copying process retains the font description information. When the article
1) doctest
Using Doctest is a similar approach to command-line attempts, and the usage is simple, as follows
The code is as follows:
def f (n):""">>> F (1)1>>> F (2)2"""Print (n)if __name__ = = ' __main__ ':Import DoctestDoctest.testmod ()
It
Python code
The code is as follows:
#-*-Coding:utf-8-*-
Import Image,imagedraw,imagefont
Import Random
Import Math, string
Class Randomchar ():
"" for random generation of Chinese characters "" "
@staticmethod
Def Unicode ():
val = Random.randint (0
For example, the format of our storage:
Format of:Name, age | Another user name, age
Name:haha,age:20|name:python,age:30|name:fef,age:55
Then we can cut the string object into a list by the split method of the string object.
A = '
The sample program is as follows:
>>> a = [-1, 3, ' AA ', 85] # define a list>>> A[-1, 3, ' AA ', 85]>>> del a[0] # delete No. 0 element>>> A[3, ' AA ', 85]>>> del A[2:4] # Removes the element starting from the 2nd element to the 4th. Including
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