Example 1, get the MySQL version
Copy Code code as follows:
#-*-Coding:utf-8-*-
#安装MYSQL DB for Python
Import MySQLdb as MDB
con = None
Try
#连接mysql的方法: Connect (' IP ', ' user ', ' password ', ' dbname ')
con = mdb.connect (' localhost ', ' root ',
' Root ', ' test ');
#所有的查询, is running on a module cursor that connects con.
cur = con.cursor ()
#执行一个查询
Cur.execute ("SELECT VERSION ()")
#取得上个查询的结果, is a single
Played a computer game of the students to plug is certainly not unfamiliar, but you use the plug-in when did you think how to do a plug-in it? (Of course, with the plug-in is not so moral ha, hehe), then we will look at how to use Python to create a plug-in ....
I opened 4399 Games Network, point opened an unknown game, well, sushi division, there is material on one side, guests come to say their requireme
Cache creation is completed using ArcGIS toolbox. In arcpy, you can use functions to call corresponding tools to automate Script Creation of cache.
There are several steps to create a cache. First, set the python environment variable. The Code is as follows:
# Set the environment variable def setworkspace (folder): If OS. Path. isdir (folder) = false: Print "the input workspace path is invalid! "Return env.
the creation of a management interface is often stereotyped. You have to authenticate users, display and manage tables, validate input validity, and so on. It's tedious and repetitive. Using Django Admin can reduce these problems. Django Admin basic style, management style is the same, Django also provides a rich interface to make developers DIY.Of course, you can also write your own back-office management that meets the needs of this site without Django Admin, and OpenStack Horizon is a set of
(): print("TEAR DOWN!") def test_basic(): print("I RAN!")You can run to ls -R view the directory structure.tests/to return to the previous level of the catalog, run the test:nosetestsUse this skeletonEach time you want to create a new project, just do the following things:
Copy the Skeleton catalogue and change the name to the name of the new project.
Rename the name directory to the name of your project, or the name you want to
In the digital currency of the popular stalls, bitcoin, the currency of the value of the money is not trustworthy. Perhaps you are as curious as many people, want to approach it, but only because of the block chain technology behind, blocking the pace of the attempt to new areas. However, for programmers, want to really understand Bitcoin, understand the block chain, is not a problem, because they can play while learning, through a line of Pyhton code, can really understand the underlying secret
Create an xml file using python
This document is an example of generating an xml file using the ElementTree class library.
# *-* coding=utf-8from xml.etree.ElementTree import ElementTreefrom xml.etree.ElementTree import Elementfrom xml.etree.ElementTree import SubElementfrom xml.etree.ElementTree import dumpfrom xml.etree.ElementTree import Commentfrom xml.etree.ElementTree import tostringimport osfilename
This article mainly introduces you about 10 minutes how to use Python to make your own personal logo of the relevant information, the main use of the word cloud to achieve this effect, the text through the sample code introduced in very detailed, to everyone's study or work has a certain reference learning value, You need a friend, let's take a look.
Objective
The use of Word clouds believe that we are not unfamiliar with the use of simple, direct ca
Original article: http://11072687.blog.51cto.com/11062687/1739870Recently found an article " Create screen using Zabbix API", and then download the script to test, found two questions:1.3.x version is not supported.2. The host name of the added screen is not arranged in order and is not convenient for querying.I changed it, let's support the zabbix3.x version, and output screen (aggregate graphics) by machine name arrangement.#!/bin/envpythonimportjso
Tuple is another ordered list, and Chinese is translated as "tuple". Tuple and list are very similar, however, once a tuple is created, it cannot be modified.The same is the name of the class, expressed as a tuple as follows:>>> t = (' Adam ', ' Lisa ', ' Bart ')The only difference between creating a tuple and creating a list is the ( ) substitution [ ] .Now, this t cannot be changed, the tuple has no append () method, and there is no insert () and Pop () method. Therefore, the new classmate can
In MY UBUNTUEnvironmental control of Python2:sudo apt-get install virtualenvCreated: virtualenv--no-site-packages [Environment Construction directory]Environmental control of Python3:sudo apt-get install python3-venvCreated: python3-m venv [Environment Construction directory]Python2 and Python3:Open the Virtual Environment directory:Enter virtual environment: source./bin/activateExiting the virtual environment: source DeactivateDelete a virtual environment: delete the Environment directory direc
'}>>> A{1: ' One ', 2: ' Both ', 3: ' Three ', 4: ' Four ', 5: ' Five '}>>> b{1: ' One ', 2: ' Both ', 3: ' Three ', 4: ' Four '}Pop ()Popitem () Random Popup>>> A.pop (2)' Both '>>> A{1: ' One ', 3: ' Three ', 4: ' Four ', 5: ' Five '}>>> A.popitem ()(5, ' five ')>>> A{1: ' One ', 3: ' Three ', 4: ' Four '}>>> A.setdefault(7, ' seven ')' Seven '>>> A{1: ' One ', 3: ' Three ', 4: ' Four ', 7: ' Seven '}>>> B = {7: ' SEVEN '}>>> A{1: ' One ', 3: ' Three ', 4: ' Four ', 7: ' Seven '}>>> A.update
I have written the test code for the fork process under Python (to show that the problem is not necessarily entirely appropriate):
def Fork (a):
def Now ():
import datetime return
Datetime.datetime.now (). Strftime ("%s.%f")
import os
Import Time
print now (), a
if os.fork () = = 0:
print ' sub-process [%s]:%s '% (now (), Os.getpid ()) while
1:
a-=10
print ' child process's a value [%s]:%s '% (now (), a)
if a
TIPS:
Matplotlib Brief Description: Matplotlib is a desktop drawing package for creating high-quality charts (mainly 2D). The project was launched by John Hunter in 2002 to build a MATLAB-style drawing interface for Python. If you use a Python IDE, such as Pycharm,matplotlib, you also have interactive features such as zoom and pan. It not only supports many different GUI backend on various operating systems, but
Python Learning -- Django -- connect to mysql to create a model
1.
Create a project
2.
Create the first page
3.
Create an app
4.
Add a page to the app
4.1
Configure in setting:
Add
Add
Create views
Then
You can access it t
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.