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
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]
Previously there was a way to convert the document format using PowerShell, but because PowerShell support was not so full, it didn't work. Here, use Python to do one more.IdeasDetect source format, if not UTF8, then convert, otherwise
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
Guibs's Python learns the Zen of _python
The Zen of Python, by Tim petersbeautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is
Guibs's Python learning _if
# if# If you control whether the code block belongs to if# if conditional_test:# does somethingcars = [' Audi ', ' BMW ', ' Subaru ', ' Toyota ']for car in car S:if car = = ' BMW ': Print (Car.upper ()) Else:print
Guibs's Python learning _while&input
# while and input# input () # input () receives a parameter: the hint or description to be displayed to the user message = Input ("Tell me what you want to say to me, I'll repeat your words ~\n") print ("You say:
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,
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
In Python, how does one obtain the composition of subarea elements from a two-dimensional list?
UsedNumPYYou should know that you can easily use the area slicing function in a two-dimensional array, such:
This function is available in the Python
The path to python: wupeiqi
Decorator:
Itself is a function (decorated with other functions), that is, adding the attachment function for other functions
Principles:
(1) the source code of the decorated function cannot be modified.
(2) The call
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