The use of Python to write a simple test host survival script, this script is not suitable for online use, because the network delay, packet loss caused by false positive mail, then the subsequent update to determine the three ping not pass the
The example in this paper describes how Python uses regular expressions to match and intercept specified substrings and the method of de-weight. Share to everyone for your reference. Specific as follows:
Import repattern=re.compile (R ' \| (\d+) \|
The python adorner can be used to modify the context of a function while it is running, that is, you can define what the function does before it executes and what it does after the function executes, and the function itself does not change anything.
Beautiful soup when used, it is generally possible to search by specifying the corresponding name and attrs, specific names and attributes to find the desired part of the HTML code.
However, there are times when there are multiple possibilities for
Nonsense not much to say, directly to everyone paste code, code write bad also go to you heroes forgive me.
#-*-coding:utf-8-*-#1, Dictionary dict = {' name ': ' Zara ', ' age ': 7, ' class ': ' First '} #字典转为字符串, return:
{' Age ': 7, '
1. Introduction to Basic Functions
(1) Standard type functions [Type (), str (), and CMP ()]Invoking the type () factory method on a dictionary returns the dictionary type: "
". Calling the Str () factory method returns the string
Python merge text File sample code.
Python implements two text merges
Work number and name are recorded in the employee file
Cat Employee.txt:
Jason Smith200 John Doe300 Sanjay Gupta400 Ashok Sharma
Record work number and salary in bonus file
Cat
Code is also found on the internet, the efficiency is very good, especially suitable for the dictionary file to the weight
#coding =utf-8import sysdef open_txt (): #打开TXT文本写入数组try: xxx = File (sys.argv[1], ' R ') for Xxx_line in Xxx.readlines ():
Prelude
To be able to manipulate the database, first we have a database, so to install MySQL first, and then create a test database python_test used for subsequent tests
CREATE DATABASE ' python_test ' CHARSET UTF8
Importing database
First, install MOD_WSGI 3.4:
./configure--with-apxs=/users/levin/dev/apache2.2.27/bin/apxs--with-python=/usr/bin/pythonmakemake Install
Edit httpd.conf Enable Apache to import the module mod_wsgi.so and introduce the Vhost configuration
1. Writing and reading of files
#!/usr/bin/python #-*-Coding:utf-8-*-# Filename:using_file.py # file is created and read s = "" We're all wood people, don't talk, don't move! " # Creates a file and writes the character F = file (' Test_file.txt ',
The example in this article describes how Pygame is displayed for game windows in Python. Share to everyone for your reference, as follows:
In this tutorial, I'll Give you a demo demo:
When we press the ' F ' key on the keyboard, the demo window
This article describes a python-based single-quote string filtering method that implements MySQL. Share to everyone for your reference, as follows:
The main use of this function, you can handle mysqldb.escape_string (content).
Class Guide:def
This paper analyzes the list operation of Python development. Share to everyone for your reference, as follows:
For the operation of list in Python, you can refer to the Python list Operation usage Summary
Here are my personal notes:
There are a
Both single and double quotation marks can represent strings. The difference is when escaping.
If you are lazy to add an escape character, you can precede the string by adding R. For example:
Print R ' C:\some\name '
Do not wrap by adding a
Near the Spring Festival, the script of the small to lead everyone with Python Rob train tickets!
First, we need splinter.
Installation:
Pip Install splinter-i http://pypi.douban.com/simple–trusted-host pypi.douban.com
Then you need a browser
Table replicationMySQL Copy table operation we will often use, the following will give you a detailed description of several MySQL copy tables, I hope you learn the MySQL copy table can be helpful.
If we have one of the following tables:
ID
(1) method one, directly with a tag of the href+ database file address, you can download. Cons: Word Excel is a direct pop-up download, for files such as image txt are downloaded directly on the new page.
(2) method Two, in the background of the
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