Implementing a simple calendar with Python
Read the current time and display this month's calendarOutput formatting
#!/usr/bin/python2#It ' s myImport time#get date Gets the current dayYear = Time.strftime ('%Y ', Time.localtime (Time.time
An If statement is used to check a condition: If the condition is true (true), we run a statement block (you are an if block), otherwise (else), we execute another statement block (called else block). Else the child statement is optional.
For
Why does the Python class method need to add self as the first argument? For example, the Python class method is defined in this way:
Class Charfield (Field):Description = _ ("String (up to% (max_length) s)")def __init__ (self, *args,
In peacetime development process often encounter needs to simulate post or get request, of course get generally directly through the browser can also be convenient and quick. Zhengxiao See the Internet also has a lot of software version of the HTTP
The code is as follows
Copy Code
One, the catch of the exceptionThere are several ways to catch exceptions: 1: Use try and except statements TryBlockExcept [Exception,[data ...]]:BlockTryBlockExcept [Exception,[data
About multiple line matches in Python non-greedy, multiline matching regular expression examplesTips for some regular:
The code is as follows
Copy Code
1 Non-greedy flag >>> Re.findall (R "A (d+?)", "a23b")[' 2 ']>>>
1. List Resolution:
Listing parsing, list comprehensions, derived from the functional programming language Haskell, is a very useful, simple and flexible tool that you can use to create lists dynamically.
Syntax for list parsing:[Expr for Iter_var
Current timestamp: Time.time ()Current date: Time.ctime ()
Get current time:
Ymdhms = Time.strftime ('%y-%m-%d%h:%m:%s ', Time.localtime (Time.time ()))Timearray = Time.strptime (ymdhms, "%y-%m-%d%h:%m:%s")
Current Time Date stamp
String formatting:
The code is as follows
Copy Code
format = "Hello%s,%s enough for ya?"Values = (' World ', ' hot ')Print format% values
Result: Hello world, hot enough for ya?Note: If not executed at the
Operation and maintenance Automation route:The development of the CMDB needs to include three parts:
Acquisition of hardware data
Api
Page Management
Execution process: The client of the server collects the hardware data, then
Read-write files are the most common IO operations. Python has built-in functions for reading and writing files, and the usage is compatible with C.Before reading and writing files, we must first understand that the ability to read and write files
In Python, sometimes the caller knows only the class name and the class method, not the actual function call, but the class name and class method that will be called to tell an intermediate function, which is responsible for the actual call of the
In this section, let's take a look at the use of cookies.Why use cookies?Cookies, which are data stored on the user's local terminal (usually encrypted) by certain websites in order to identify users and perform session tracking.For example, some
Original link: https://my.oschina.net/u/2344787/blog/400507?p={{page}} 1. Selenium Webdriver The Get method will wait until the page has finished loading before executing, but if the load time is too long it will cause subsequent operations to
Character encodingWhen the Python interpreter loads the code in the. py file, the content is encoded (default ASCII)BinaryExample: Ancient beacon, ignition and not ignition only two states, the transmission of information too little.Agreed ignition
It's also worth noting that's can use * and * * when calling functions as well. This is a shortcut the allows you to pass multiple arguments to a function directly using either a list/tuple or a dictio Nary. For example, if you have the following
Recently doing a scan code login function, for this I also searched the internet about the implementation of the scan login. When this function was completed, I decided to organize the whole realization, so that I can see it later and also
Python regular expressions are frequently applied to string substitution code in use. A lot of people do not know how to solve this problem, the following code tells you that the problem is extremely simple, I hope you have something to gain.
1.
1. To install VIM, you can install it using the Apt-get tool that comes with Ubuntu.
Apt-get Install Vim-gnome
2, after the installation is successful, configure
1> first automatic hint completion configuration (pydiction)
From the official
(Reprinted) python date function, reprinted python date function
Reprinted on http://www.cnblogs.com/emanlee/p/4399147.html
All Date and Time APIs are in the datetime module.
1. format the date output datetime => string
Import datetime
Now =
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