Recently used Python to write a remote monitoring program, the main features are:1. Use Mail control so function2. Can screen capture, screen capture sent to the mailbox3. Can use the camera to obtain pictures, these pictures upload to seven cattle4.
Through the pyfetion can be very convenient to use Python to send text messages, the following posted code:
Copy Code code as follows:
From fetion Import *
Import OS
def sendsms (SMS):
Myphone = ' xxxxxx '
MyPwd = ' oooooooooo '
Batch modify Linux server password, generate execl form
Copy Code code as follows:
#!/usr/bin/env python
#coding: UTF8
#随机生成自定义长度密码
From random import choice
Import String,pickle
def genpassword
Python uses the cTYPES module to invoke the Windows API GetVersionEx get the current system version without using the Python32
Copy Code code as follows:
#!c:/python27/python.exe
#-*-Coding:utf-8-*-
"To determine the current system
The definition of a tree
Tree-shaped structure is a kind of important nonlinear structure. A tree structure is a structure with a branch and a hierarchical relationship between nodes. It is very similar to the tree in nature.Recursive definition of
The idea of sqlalchemy is that the scale and performance of SQL databases are important to the collection of objects, while the abstraction of object collections is important for tables and rows.One installation SQLAlchemy
Copy Code code as
The first 2 methods are mainly used in list parsing, performance is slightly poor, and the last use of the generator expression, compared to list parsing, more memory-saving
List resolution and builder expressions are similar:
List resolution
Copy Code code as follows:
#!/usr/bin/env python
Import Sys,time
From socket import socket
def read_interface (in_file):
With file (In_file) as F:
return F.readlines () [2:]
def set_interface (inter_msg):
dic={}
For i in Xrange (Len
Python opens the browser, you can do a simple brush the Web applet. Only for study, not for illegal use.
Python's WebBrowser module supports some of the following three ways to do the browser:
Copy Code code as follows:
Scenario: A folder contains a large number of files that need to be stored in a different directory by group (for example, 5,000 groups).
Copy Code code as follows:
# Filename:CopyFiles.py
Import OS
Import Os.path
Folder_capacity =
First, sort lists (list)
The recommended sort is to use the built-in sort () method, which is the fastest and stable sort
Copy Code code as follows:
>>> a = [1,9,3,7,2,0,5]
>>> A.sort ()
>>> Print a
[0, 1, 2, 3, 5, 7, 9]
>>>
Python, with its graceful syntax and handy built-in data structure, has won the close gaze of many programmers.One of the most useful data structures is the dictionary (dict), which is very simple to use. When it comes to traversing a dict structure,
I. Definition and use of classes
The basic syntax for Python to define a class is:
Copy Code code as follows:
Class ClassName ([base class one, base class two ...]):
[Def __init__ (self, [agv1,agv2 ...]):] # define
In general, Python has a lot of variable/data types, but it doesn't need to be specified by the user, because some are generated based on partial system functions , others are automatically identified by the values of variables, which are constants
First, Introduction
With is a new syntax introduced from Python 2.5, more precisely, a context management protocol that simplifies the processing of try...except...finally. With the __enter__ method to initialize, and then do the cleanup in the
Recently to do their own development with the relevant services of a checklist, wrote this script, used in the springboard to check the server above the relevant services are normal
Use expect to log on to each machine (because of security issues,
Copy Code code as follows:
# OS ModuleOS.SEP can replace the operating system-specific path separator. Windows is ' \ \ '
The Os.name string indicates the platform you are using. For example, for Windows, it is ' NT ', and for Linux/unix
Splinter Quick IntroductionOfficial website: http://splinter.cobrateam.info/Official Introduction:Splinter is a open source tool for Testingweb applications using Python. It lets your automate browser actions, such asvisiting URLs and interacting
#/usr/bin/env python #-*-coding:utf-8-*-"" "1. Resolves five parameters (time-sharing and eclipses) in the crontab configuration file to obtain their corresponding range of 2. One row of time parameters in the timestamp and crontab configuration
In Python, there are four ways to traverse Dict. But what about the performance of these four kinds of traversal? I did the following tests
L = [(x,x) for X-xrange (10000)]
d = dict (l) From time
import Clock
t0=clock () to
i in D:
t = i + D
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