Write a simple message in python that needs to be sent with a custom message that can be used to monitor the sending of alert messages.#!/usr/bin/env pythonImport Smtplib//built-in SMTP libraryImport stringHost = "smtp.163.com"//define the hosts
1. Convenient data acquisition1.2 Network data acquisition:1.2.1 Urllib, Urllib2, Httplib, httplib2 and regular expressions (Python3 in Urllib.request, http.client)Get AXP stock data for nearly a year2. Data preparation and collation3. Data display4.
1. Form[Expression for variable in list] or [expression for variable in list if condition]2.demo#!/usr/bin/python#-*-Coding:utf-8-*-Li = [1,2,3,4,5,6,7,8,9]print [x**2 for x in Li]print [x**2 for x in Li if x>5]Print Dict ([(X,X*10) for x in
Import SYS #导入sys库Print (Sys.path) #打印环境变量#print (SYS.ARGV) #sys. argv[] is used to get command-line arguments, Sys.argv[0] represents the file path of the code itself, such as "Python test.py-help" in the cmd command line, then sys.argv[0]
1. ABS (number) indicates the absolute value of a digitPrint # Print out 1232, All (iterable) indicates that the iterated parameters are all true then return true, otherwise false# The argument is iterative and returns true if the argument is all
Q&a:
1. Why is it not available for a period of time to show embarrassing encyclopedia?
A: The previous time because the embarrassing encyclopedia added the header of the test, resulting in the inability to crawl, you need to simulate the header in
Before we start, let's explain two methods in Urllib2: info and Geturl
Response (or Httperror instance) of the reply object returned by Urlopen has two useful methods, info () and Geturl ()
1.geturl ():
This returns the actual URL obtained, which
Python implements binary search and bisect module details, pythonbisect
Preface
In fact, the Python list is an array, that is, a linear table. You can uselist.index() Method. The time complexity is O (n ). For large data volumes, you can use binary
Python uses OS. remove to delete folders,
OS. remove cannot be used to delete folders; otherwise, access is denied.
#-*-Coding: UTF-8-*-import osif _ name _ = "_ main _": OS. remove ('d: \ test ')
Running result:
Delete an empty directory:
#-*
Python scientific computing-NumPy getting started, pythonnumpy
Preface
NumPy is a fast mathematical library used by Python to process large matrices. It allows you to perform vector and matrix operations in Python, and many underlying functions are
Use pymysql to add, delete, modify, and query mysql in python (Comprehensive), and pymysqlpython
This time, we will use pymysql to perform all the operations for adding, deleting, modifying, and querying MySQL, which is equivalent to the previous
Ansible is an example of the method used by the python module library. ansiblepython
Preface
Ansible is a new automatic O & M tool developed based on Python. It integrates the advantages of many O & M tools (puppet, cfengine, chef, func, fabric,
Summary of exceptions in Python, pythonexception
Preface
Exception classes are common Exception classes, including StandardError, StopIteration, GeneratorExit, and Warning. Exceptions in python are created using the inheritance structure. You can
Yield from syntax in Python 3, pythonyield
Preface
Recently, I am playing the drums Autobahn. It provides an example based on asyncio. I want to say that I can run it on pypy3 ...... Failed.pip install asyncioI directly reported invalid syntax, and
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