Use Lambda in Python to create anonymous functions. Lambda comes from the lisp language. The Lambda format is as follows:
Lambda arg1, arg2....: Lambda creates a function object, but does not assign this function object to an identifier. Def is different. It performs this operation when creating a function object. This is the first feature of Lambda. Lambda's second feature is that it is just an expression,
Python code to create a configure file example,
In lua, you have always used lua as a config file or a file that carries data. The advantage is that lua itself is well-read, and no extra parsing code is required, you can also read environment variables and condition judgments in configure files.
Use loadfile and setfenv in lua)
Python:
Cat config. pybar = 10f
Two commands create Vim as the Python IDE method, vimpython
Run the following two commands to configure Vim (including plug-ins) to Python IDE. Currently, MAC and Ubuntu are supported.
curl -O https://raw.githubusercontent.com/vince67/v7_config/master/vim.shbash vim.sh
Example
What have you done?
A convenient bash script is written to configure VIM
The configur
function of XPath is to use these tags to find specific information.Browser F12 Open the debug console,Refers to the information, the right side will show the corresponding codeRight click on a good thing,This can be used. Unfortunately, scrapy is often not recognized, so we also need a bit of XPath syntax (check 10 minutes to fix), refer to copy's own modification. This plugin, which is recommended by Chrome's XPath helper, can see that the XPath you are writing is not correct.def parse_item (
, 61.58482111, 69.51927962, 78.47599704, 88.58667904 . ])In addition, functions such as Frombuffer, FromString, FromFile, and so on can be used to create an array from a sequence of bytes, with FromString as an example:>>> s='abcdefg'>>> numpy.fromstring (s,dtype=97, 98, 101, 102, 103], dtype=int8)The first parameter of the FromFunction function is the function that evaluates each array element, the second parameter is the size
With Pywin32, can you do whatever you like on Windows?Yes.#-*-coding:cp936-*-# import osimport pythoncomfrom Win32com.shell import shellfrom Win32com.shell import shellcondef Set_shortcut (filename,lnkname,iconname): #如无需特别设置图标, you can remove the iconname parameter shortcut = pythoncom. CoCreateInstance (Shell. Clsid_shelllink, None, pythoncom. Clsctx_inproc_server, Shell. Iid_ishelllink) shortcut. SetPath (filename) shortcut. Seticonlocation (iconname,0) #可有可无, does not use the default file
Create a tuple of PythonTuple 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, thetuple has no append () method, and ther
The dictionary is the only built-in mapping type in Python. The values in the dictionary are not in a particular order, but are stored in a particular key.
A key can be a number, a string, or even a tuple.
1. Creating and Using dictionaries
Dictionaries can be created in the following ways:
Copy Code code as follows:
Phonebook = {' Alice ': ' 2341 ', ' Beth ': ' 9102 ', ' ceil ': ' 3258 '}
A dictionary consists of multiple keys
what to add, the moment has not thought how to partition it ...) )Microblog-app__init__.pyviews.py-static-templatsrun.pyInitialize app\__init__.py from Import Flask
= Flask (__name__)
fromimport views Writing an attempt to function # app\views.py
from Import app
@app. Route ('/')
@app. Route ('/index ')
def index ():
Pass The final step to making the Web app fully operational is to create a script that launches the application Web serve
Instance 1. Obtain the MYSQL version
Copy codeThe Code is as follows:#-*-Coding: UTF-8 -*-# Install mysql db for pythonImport MySQLdb as mdbCon = NoneTry:# Method for connecting to mysql: connect ('IP', 'user', 'Password', 'dbname ')Con = mdb. connect ('localhost', 'root ','Root', 'test ');# All queries are run on the cursor module connected to con.Cur = con. cursor ()# Execute a queryCur.exe cute ("select version ()")# Obtain the result of the previous query, which is a single resultData = cur.
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:
Monkeyrunner script writing skills (ShellCommand, file operations)
Android 4.0 has been released. I am disappointed that the monkeyrunner tool has not greatly improved and the SDK does not seem to have changed much. However, I will see the trend before, the Source Code has introduced new modules such as ichampview and runtime. Unfortunately, the source code has not yet been released and the specific situation is unknown. Besides, the current monkeyrunner cannot be executed. I feel that there are
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.