python-sending mail

From: Http://www.cnblogs.com/lonelycatcher/archive/2012/02/09/2343463.html#commentform #!/usr/bin/env Python3 #coding: Utf-8  import smtplib  fromimport mimetext  fromimport header  Sender = ' * * * '

Python Learning Notes

If you want to run the py file directly, you need to add it on the first line:# !/usr/bin/env pythonIn the directory where the files are entered:./filename.pyHowever, you will be prompted with an error: Permission denied, to avoid such an error,

Python Learning note seven: shallow copy deep copy

PrincipleShallow copyImport= Copy.copy (a)Demo>>> a=[1,['a']]>>> b=a>>> c=Copy.copy (a)>>>a[1, ['a']]>>>b[1, ['a']]>>>c[1, ['a']]>>>ID (a)140556196249680>>>ID (b)140556196249680>>>ID (c)140556298139120>>> a[0]=2>>>a[2, ['a']]>>>c[1,

Python Regular Expressions

1. \d can match a number. ' 00\d ' can match ' 007 '.2. \w can match one character. ' \w\w\d ' can match ' py3 '.3.. can match any character. ' Py. ' Can match ' PYc ', ' pc0 ', ' py! ',4. * denotes any character (including 0).5. + represents at

Python Learning note 25 (File Management OS package)

OS PackageWe often deal with files and directories, and for these operations Python provides an OS module that contains many functions for manipulating files and directories. If you understand Linux basic operations, some of the following OS

Python Learning note four: lambda expressions and switch

First, the definitionLambda arg1,arg2 ...: returnvalueIi. Examples# !/usr/bin/python def f (x, y ): return x*yprint f (2,3)#6Lambda x,y:x*yprint g (2,3)#6Third, switch of a realization scheme#!/usr/bin/python from __future__ ImportDivision#A=int (

Python Learning Note III: functions

First, the definitiondef functionname ([arg1,arg2,...]): codeIi. examples#!/usr/bin/python#Coding:utf8#Coding=utf8#Encoding:utf8#Encoding=utf8defFun (x=3,y='Sweet'): Print 'generates a'X'Yuan'Y'Flavors of Cakes'Fun ( ) Fun (10) Fun

The road to mathematics-distributed computing-hadoop, Python and R (3)

Second, Ubuntu 12.04hadoop2.6 configuration and installation1. Java7 Configuration#su#addusermyhasplAdd SU permissions belowMake MYHASPL users belong to the sudo group#vi/etc/groupSudo:x:27:,myhasplAnd then restart#rebootGo to MYHASPL user and start

Python easy_install CentOS installation process and principle analysis

First, Easy_install installation processThere are many kinds of installation process, I also looked for a lot of examples, but the results are not very good, the following methods are good results.Similar to Yum, Easy_install uses Easy_install to

In Python if __name__ = = ' __main__ ': parsing

Http://www.cnblogs.com/xuxm2007/archive/2010/08/04/1792463.htmlWhen you open a. py file, you will often see if __name__ = = ' __main__ ' at the bottom of the code: Now let's introduce its role.The module is an object, and all modules have a built-in

Python Read and write files

A simple example:Write the input to the created file:Import Osls= Os.linesep #Win is '\ r \ n'and Linux is '\ n'FileName= Raw_input ('Please enter your file name here:') whileTrue:ifos.path.exists (fileName): Print'the file "%s" has already existed'%

A detailed copy of the depth in Python

To get a clear picture of a deep copy in Python, you need to figure out the following concepts:Variables-References-Objects (Mutable objects, immutable objects)-slices-copy (shallow copy, deep copy)" Variable-Object-Reference "In Python everything

Python gets today's date

http://www.sharejs.com/codes/python/8032Import DateTime # Get a date Objecttoday = Datetime.date.today () # General functions print ' year:%d '% Today.yearprint ' M Onth:%d "% today.monthprint" day:%d "% today.dayprint" Weekday:%d "% today.weekday (

Python read Chinese

How do I read 300 characters from a file?It looks simple, but it's easy to fall into the pit.At first I wrote this:1 Try:2FD = Codecs.open (Os.path.join (settings. Text_content_dir,channel_name.lower (), article_id), encoding='Utf-8')3

Python matplot Picture Histogram (i)

The existence of graphs to visualize data. No matter how complex things are, they are simple combinations.1 ImportMatplotlib.pyplot as Plt2 ImportNumPy as NP3Dict = {'A': 40,'B': 70,'C': 30,'D': 85}4 forI, keyinchEnumerate (dict):#circulate both

Python gets a number for the current one month

#-*-coding:utf-8-*-Import timenowyear = Time.localtime () [0]nowmonth = Time.localtime () [1]lastmonth = Nowmonth-1if No Wmonth = = 1:lastmonth = Nowyear = Nowyear-1result = "%s-%s-%d"% (Nowyear, lastmonth, 1) timestamp=time.mktime (t Ime.strptime

Python Django Shell Debugging

Python Django Debugging >>> class person (models. Model): ... First_Name = models. Charfield (max_length = ...) Last_Name = models. Charfield (max_length = ...) def __unicode__ (self): ... return u '%s '% (Self.first_name,

Python Learning Notes (group)

In a regular expression, group () is used to present a string that is intercepted by a packet ,() to group ImportRea="123abc456"PrintRe.search ("([0-9]*) ([a-z]*) ([ 0-9]*)", a). Group (0)#123abc456, return to the wholePrintRe.search ("([0-9]*)

Python study NOTE 2: Process Control and python study note Process

Python study NOTE 2: Process Control and python study note Process1. if else: #!/usr/bin/pythonx = int(raw_input('please input:'))if x >= 90: if x >= 95: print 'a+' else: print 'a'elif x >= 80: if x >= 85: print 'b+'

Python script for file cleanup,

Python script for file cleanup, Since I first wrote a blog on cnblog, I found that the webpage version could not be directly pasted with images. With the help of a mac computer, the shortcut key saved the images on the table. In addition, a lot of

Total Pages: 4013 1 .... 3991 3992 3993 3994 3995 .... 4013 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.