#!/usr/bin/env python#--*--coding:utf-8--*--" "An example of reading and writing Unicode string:writes a unicodestring to a file in Utf-8 and reads it back in." "CODEC='Utf-8'FILE='Unicode.txt'Hello_out= u"Hello world\n"Bytes_out=Hello_out.encode
First, the function of the programming of the sending of e-mail#!/usr/bin/env python#-*-Coding:utf-8-*-Import SmtplibFrom Email.mime.text import MimetextFrom email.utils import formataddrdef mails ():msg = mimetext (' message content ', ' plain ', '
Under Windows:After downloading the Python installation on the Web site, it is not possible to use Python directly under CMD, because in Windows we have to set the PATH environment variable in order to find the program by path PATH.Win7
>>> ' abc ' + ' Def '' ABCdef 'Python allocates space for ' abc ' and ' Def ' respectively, and Python automatically allocates space for the new string ' abcdef ' When the connection operation is made>>>s = ' abc '>>>s = s + ' def '>>>s' ABCdef 'In
| Append (...)| L.append (object)--Append object to end|| Count (...)| L.count (value), integer--return number of occurrences of value|| Extend (...)| L.extend (iterable)--extend list by appending elements from the iterable|| Index (...)| L.index
Adorner:1, the adorner is a function, at least two layers of function.2, for example @auth: Perform auth ah function, decorated function as parameter auth (foo)The return value of the AUTH function, assigned to the function name of the decorated
Reprint: http://www.iteye.com/topic/550804collect.py, this can only be used under Linux ... #!/usr/bin/pythonBecause the traceroute command is usedImport sysimport osimport threadimport cpickleimport timeimport refrom socket import inet_ntoafrom
In the use of Python sometimes always forget a lot of code, this is the most headache for the program Yuan thing, I was just contact Python, these days is also used this piece, so recorded, has been needed to be able to find.My system is:[Email
In some cases, it may be necessary to work with multiple adorners at the same time, in particular how to use, see Code:#basic5. Pydef auth1 (func): Def inner (): print ' before 1 ' func () print ' after 1 ' return innerdef Auth2 (func): Def inner ():
From the second version of Python's core programming, this essay is just for the sake of making a deeper impression.Environment OS X python version 2.7.101 #!/usr/bin/env python2 #--*--coding:utf-8--*--3 4 'maketextfile.py--Create text file'5 6
1.1 Why would you choose Python?Describing Python as an object-oriented scripting language may be the most appropriate.Python is object-oriented and can be used as a scripting tool for languages such as C + +, Java (mixed).Python is open source
To explore something, we need to know what this thing is used for, what it can bring to us, what kind of problem is solved, what are the pros and cons, and so on; a brief look at the characteristics of a Python virtual machine:There are currently
Small way to share it here.[[email protected] dist-packages]# pythonPython 2.7.5 (default, June 17 2014, 18:11:42)[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2Type "Help", "copyright", "credits" or "license" for more information.>>> Import Tab>>>
Function basicsCount the number of characters in a string1 def countsubstring (s,ch): #s和ch为形参2C=03I=04 whileiLen (s):5 ifs[i]==Ch:6c + =17i + =18 print (c)9Str='WUJIADONGJIANGRUISUIRSUIUIGJSJSIUISLDJSJEUIUI'Tenm= ' I '
1. Installation in Linux system:As long as the Linux operating system, the default is already installed in Python. It may not be the latest version, as long as the python2.7.x version is available.If you do not want to install yourself, you can
Python User InteractionHere, a user interaction is used to determine the user output name and receive different responses. Color the name.
# Coding: utf-8name = raw_input ('What is your name? : ') Age = raw_input ('How old are you? : ') Job =
Import and use of the python ModuleLet's take a look at the python module import and use [root @ web-02 dist-packages] # cat indentation. py
#!/usr/bin/enb pythonversion = 'v1.0'author = 'Madon'def sayHi (n): print 'hi , this is a module.',n
//
Write excel in pythonFirst, you must
Pip install XlsxWriter # coding = utf-8import xlsxwriter # Create an new Excel file and add a worksheet. workbook = xlsxwriter.workbook('demo1.xlsx') worksheet = workbook. add_worksheet () # create a table
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