Use of transparent channelsPutalpha (Alpha)This method is a magical way, you can write a picture (and the original size of the same) to the original image of the transparent channel, without affecting the normal display of the original picture, can be used for information hiding oh. Of course, the premise is that the originalThe initial picture has a transparent channel. However, even if it is not much of a relationship, because there is the CONVERT function provided by PIL, you can convert a pi
"""#-*-coding:cp936-*-# Find all primes in theT=[]def num ():For I in Range (1,501):If i%2!=0:print ' is a prime number ', IPrint num ()#!/usr/bin/python#-*-Coding:utf-8-*-#there is no + + operator in PythonImport stringdef main ():S=raw_input (' Please enter : ')Letter=0Space=0Digit=0Other=0For I in S:If I.isalpha ():Letter+=1Elif I.isspace ():Space+=1Elif I.isdigit ():Digit+=1ElseOther+=1print ' you entered the letter %d:, space %d:, number %d:, other %d: '% (Letters, Space,digit,other)If __n
#-*-coding:cp936-*-# Write a change procedure, require the user to enter the payment amount and the bill, the program is determined to find change for a few yuan, a few corners, a few !Def YH ():# Payment amount - bill = change ( remaining )Q1=raw_input (' Please enter your payment amount as:')Q2=raw_input (' Please enter your bill as:')#q1 indicates the amount of payment entered#q2 represents the bill entered#q3 means change ( the rest )Q1=int (Q1)Q2=int (Q2)print ' you need to pay the amount
Vulnerability Address:The Anbang Insurance Group has a logical loophole to traverse User ID Brute force user password to reset user password (script included)http://www.wooyun.org/bugs/wooyun-2010-0119851The script POC is as follows:Key: Logical point, Web request, nested#!/usr/bin/python#Coding:utf-8ImportSysImportUrllibImportUrllib2defGet_headers (DT):headers = {'Accept':'*/*','X-requested-with':'XMLHttpRequest','user-agent':'mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like
Python is already installed on the machine, and the environment variables are well configured
Write Good xx.py file
Install Pywin32. It is important to note that Pywin32 has 32-bit and 64-bit points. You can enter Python at the command prompt to see the version of Python and whether it is 32-bit or 64-bit (my Python is 2.7.9 32-bit)
To install Pyinstaller, simply extract Pyinstaller to any location and then go to Pyinstaller setup.py location at the command prompt, enter setup.py instal
Python is one of the most famous micro-web frameworks.
The installation is very simple. Download the idea (of course, you must configure the python environment before ).
Create a code. py file with the following location:
#-*-Coding: UTF-8-*-import weburls = ('/(. *) ', 'index') APP = web. application (URLs, globals () class index: def get (self, name): If not name: Name = 'World' web. header ('content-type', 'text/html; charset = UTF-8 ') return '
I'll have to admit that... it was so easy to use $ _ file for file uploading in PHP.
Trying to switch to python from PhP (for varous reasons including shared Configuration between web and background processes, etc ). started looking at web. PY (with other alternatives as well) and, surprisingly, found that the webpy's document is nothingMore than... Nothing. Even the "receipts" in "cookbook" are for those who don't need them. So I'm lost totally
Set is similar to Dict and is a set of keys, but does not store value>>> s = set([1, 2, 3])>>> s{1, 2, 3}Note that the parameter passed in [1, 2, 3] is a list, and the display {1, 2, 3} only tells you that the set has 3 elements, the order of the display does not indicate that the set is ordered.Repeating elements are automatically filtered in set:>>> s = set([1, 1, 2, 2, 3, 3])>>> s{1, 2, 3}You can add(key) add elements to a set by means of a method, and you can add them repeatedly, but with no
When the py file is converted to the exe file, it contains the paramiko module error solution, pyparamiko
Problem description: The python code contains the remote ssh logon of the paramiko module. An error is reported when the python installer is used to convert it to the exe,
The error message is "No handlers cocould be found for logger" paramiko. transport"
Error location:
Ssh = paramiko. SSHClient ()Ssh. set_missing_host_key_policy (paramiko.
The ImportError: No module named 'pefile' error solution is displayed when pyinstaller packages The py file into an exe file !,
First, for installation and use of pyinstaller, see the following link;
After the installation is complete, enter pyinstaller in the command line and the result is as follows:
ImportError: No module named 'pefile'
The module pefile is missing. The reason for Google's error is that I installed the pyinstaller version 3
)Print (' Run Tstr.pop (1), Tstr is ', tstr)Tstr.pop (-1)Print (' Run Tstr.pop ( -1), Tstr is ', tstr)# # Other data can also be used in arraysTSTR2 = [' Z1 ', ' Z2 ']Print (' Tstr2 is ', TSTR2)Tstr.insert (1,TSTR2)Print (' Insert tstr2, Tstr is ', tstr)Tstr2.insert (2, ' Z3 ')Print (' After TSTR2 changed, Tstr2 is ', TSTR2)Print (' After TSTR2 changed, Tstr is ', tstr)# # defines and references a tuple array, uses (), cannot be modified after a tuple definition, 1 elements must be defined with
;python Built-in scope in the current module , the scope of the outer scope cannot be modified directly by the inner scopes variable , to modify the global keyword and the nonlocal keyword to be used Global keyword When the modified variable is on the global scope, use global to declare it first. nonlocal keywords The variables declared by the Global keyword must be on the global scope, not nested scopes, and when you want to modify the nested scope (enclosing scope, outer non-global scope)
Official Document Https://docker-py.readthedocs.io/en/stable/1. Installing the Docker moduleIf you do not specify a version, the default installation is up-to-date, and the following error is reported if a mismatch occurs (the workaround is to specify the client version when you define the client)docker.errors.apierror:400 client Error:bad Request ("Client is newer than server (client API version:1.26, Server API version:1.24) ")Pip install docker-i http://pypi.douban.com/simple--trusted-host py
Python locals () function actionHttp://www.runoob.com/python/python-func-locals.htmlThe locals () function returns all local variables of the current position in the dictionary type.For functions, methods, lambda functions, classes, and class instances that implement the Call method, it returns TRUE.Locals () instance>>>def runoob(arg): # 两个局部变量:arg、z... z = 1... print (locals())... >>> runoob(4){'z': 1, 'arg': 4} # 返回一个名字/值对的字典>>>[PY
Because of business needs, we need to use Python to clean up some container that are dead, of course, we can use Docker ps-a and then filter the container with the status of dead, now we have a better choice: docker-py
Official Document Address: https://docker-py.readthedocs.io/en/stable/
Here's a simple use:
>>> from Docker import Client>>> CLI = Client (base_url= ' Unix://var/run/docker.sock ')
And then we're going to get all the exited and dead
Non-ascii character ' \xe7 ' in File ex6.py ' # 1, but no encoding declare error occurred in Python
You can view http://www.python.org/peps/pep-0263.html on the wrong suggestion URL
The discovery is because Python does not support encoding in the source file in the default state. The solutions are as follows: three
First, add the following annotation code to the head of the file:
# coding=
Second, add the following two lines of comment code to
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.