1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 ImportOS4 5 __author__='Virtuous'6 #Get current directory7Currentpath =OS.GETCWD ()8 Print(Currentpath)9 #C:\Users\ Virtuous \pycharmprojects\pydemoTen One #returns all file and directory names under
The most recent use of random numbers, the query data summarizes the Python random module (get random number) common methods and use examples.1,random.randomRandom.random () is used to generate a random number of 0 to 1 points: 0
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8B/48/wKioL1hJACzjbzDDAAHlVRZi_kU399.png-wh_500x0-wm_3 -wmp_4-s_2045683009.png "title=" 21.png "alt=" Wkiol1hjaczjbzddaahlvrzi_ku399.png-wh_50 "/>The site is a VMware virtual machine set up
Using the Python script to analyze Nginx log content, the default statistics IP, access URL, status, you can modify the script to analyze other fields.First, how the script runsPython count_log.py-f Med.ihbedu.com.access.logIi. contents of the
Say no to practice fake Bashi, learn Python with a small script. A simple backup script. #!/usr/bin/env python3#-*- coding:utf-8 -*-#for backupimport osimport time# Directories that need to be backed up source = ['/var/log/history/',
Always feel that their blog is too simple, today want to add a function up, say dry, ready to add a most commonly used, weather forecast function.See a few examples, think also is not very difficult, online find an interface is, however, this Baidu
can use the Smtplib module to implement the function of sending mail, a relatively simple example code is as follows:
# import Smtplib for the actual sending FunctionImport smtplib# Import The email modules we ' ll needfrom Email.mime.text im Port
The function strftime () operates somewhat like sprintf (): Identifies a collection of formatting commands that begin with a percent sign (%), and the formatted output is placed in a string. The format command describes the exact representation of
function Description Int (x [, Base]) converts x to an integer long (x [, Base]) converts X to a long integer, float (x) converts x to a floating-point number complex (real [, Imag]) Create a
When we develop a Web service, we may use a JSON-based Web service protocol. If you use the Python language for development, its extensions are messages that can be processed directly in JSON format. For example, the Python JSON module introduced in
Usually open a Web page, in addition to the text content of the article, there will often be a lot of navigation, advertising and other information. The purpose of this blog is to show how to extract the body content of the article from a Web page,
Task:
You want to back up the modified files in a directory tree multiple times to prevent a modification from accidentally erasing your edits. Periodically execute the following Python script to back up files in the specified directory.
#-*-coding:
Class Private methods
__private_method begins with two underscores, declares that the method is private and cannot be called outside of a class.
Calls Slef.__private_methods inside the class.
The proprietary methods of the class:
The __init__
Objective
After the WAF is on line, the most processed is the false positives elimination.
There are a number of reasons for false positives, such as allowing the client to submit too many cookies when the Web application source code is written,
#-*-coding:cp936-*-#---------------------------------------------# # Autho R Chile # version 1.0 # Date 2014-02-17 # desc Two fork Tree # # # #--------------------------
The Python OS Library has many operating system-related features.
In fact, not only that, the OS library has a lot of files, paths, execution system commands related.
The following are common methods for OS modules.
1.OS.SEP can replace operating
Python list Go heavy
A. {}.fromkeys (list). Keys ()
List2 = {}.fromkeys (list1). Keys ()
Two. Set
List2 = List (set (List1))
Three. Itertools.grouby
ids = [1,4,3,3,4,2,3,4,5,6,1]
Ids.sort ()
it = itertools.groupby (IDs)
For K, G in
first, AbnormalWhat is an exception?Is the event that affects the normal execution of the program, the exception occurs during the execution of the program, when the script is abnormal, we need to capture it, or the program Terminates.Exception
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