Scenario: calculate the number of independent IP addresses in the log file, that is, unique visitor.
Calculation amount: about 0.7 million records per hour, 24 hours per day, about-records
At the beginning, I thought of using a list to save
In tkinter, for example, a control is associated with a function, such as a button.CodeAs follows:
Button = button (window, text = 'lowdown ', command = click)
Here, the click function is associated with the button plug-in, but it is difficult to
During this time, ACM was in a particularly bad state. After some suggestions, I learned about Python and found that python is really powerful and Its syntax is concise and clear, it is easy to use (though not ).
When reading Liu lujia's White Book,
1. Duplicate member variables with member functions
Data attributes with the same name overwrite the method attributes. To avoid possible name conflictsProgramWhich may be hard to find
Bug-it is best to avoid conflicts with some naming
General Method
The first parameter must be self, and the instance itself
Instance_class.method ()
Class Method
The first parameter is class, which is the class itself.
Class_name.method ()
This can also be instance_class.method ()The first
Function:
Getpass.
Getuser
(
)
Explanation:
Return the "Login Name" of the user. Availability: Unix, windows.
This function checks the Environment Variables
LOGNAME,
1. nameerror: access an unstated variable>>> VNameerror: Name 'V' is not defined
2. zerodivisionerror: the divisor is 0. >>> V = 1/0Zerodivisionerror: int division or modulo by zero
3. syntaxerror: syntax error >>> IntSyntaxerror: Invalid Syntax
^ Matches the start position of the input string. If the multiline attribute of the Regexp object is set, ^ matches the position after '/N' or'/R. $ Matches the end position of the input string. If the multiline attribute of the Regexp object is set,
10.1 to enable Apache to run python, install Python and mod_python on the Apache server.
Different Versions of mod_python have strict restrictions on supported Apache versions and Python versions,You must pay attention to the download and find the
On the divew.python website.
From sgmllib import sgmlparserclass urllister (sgmlparser): def reset (Self): sgmlparser. reset (Self) self. URLs = [] def start_a (self, attrs): href = [V for K, V in attrs if k = 'href '] If href: Self. URLs. extend
# Fig. 2.13: fig02_13.py
# Displaying an object's location, type and value.
# Prompt the user for InputInteger1 = raw_input ("enter first INTEGER:/N") # Read a stringPrint "integer1:", ID (integer1), type (integer1), integer1# Print the identifier,
This book is very interesting. I used Python and pygame modules for game development, learning, translating, and writing.
Http://download.csdn.net/detail/abclixu123/4582805: this is a book.
The second chapter introduces some basic knowledge about
Type returns the Data Type of any object.
>>> Type (1) type ('A ') type (1, 2 )) type ([1, 2]) type (type)
ABS return absolute value
>>> ABS (1) 1 ABS (-1) 1 ABS (-0.001) 0.001 ABS (1 + 1j) 1.4142135623730951
Ord and CHR
Similar to other programs on the Internet, a global replacement function is added here.
You can replace the entire document to perform global replacement operations such as translation and troubleshooting.
#-*-Coding: UTF-8 -*-
Import OS, types,
Instance attributes and class attributesTheoretical Basis
Class attributes are similar to static variables in C ++. You can directly access them through class name. attribute.
The instance attribute is the attribute that can be used only after the
_ Slots _ is used to restrict instance attributes in the class. Each instance object X has a dictionary X. _ dict __. python allows you to bind arbitrary attributes to X instances through this dictionary. defining a class attribute named _ slots _
The observer mode defines one-to-many dependencies between objects. When a topic object changes, the dependent objects will receive notifications and update automatically, the observer mode has two modes: 'push' and 'pull '. I implement the 'push'
Turn: http://ihipop.info/2010/10/1777.html
Python code
# Initialize a dict
>>> D = {'A': 1, 'B': 0, 'C': 1, 'D': 0}
# The intention is to traverse dict. If the element value is 0, delete it.
>>> For K in D:
... If d [k] = 0:
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