python里stuff_Stuff about Python

- unimport  a module

importsysimportAA.BB as CC;del sys.modules["AA.BB"]

- function trace

def flog(format, *params):print("mytest:"+format %params)defmyfunction(a, b)

flog("%s %s", sys._getframe().f_code.co_name, locals())pass

- replace '\' with '/':

full_path = os.path.realpath(__file__);

full_path = full_path.replace('\\','/')

http://www.pythonscripting.com

A Brief Introduction to Python with Only One Figure

20 of the Best Free Python Books

1. Think Python

2. Invent Your Own Computer Games with Python

3. Snake Wrangling for Kids

4. Learn Python the Hard Way, 2nd Edition

5. Natural Language Processing with Python

6. Building Skills in Python

7. Dive into Python

8. Text Processing in Python

9. The Standard Python Library   *

10. The Definitive Guide to Pylons

11. Making Games with Python & Pygame

12. Python Module of the Week

14. Think Complexity

15. Data Structures and Algorithms with Object-Oriented Design Patterns in Python

16. Programming Computer Vision with Python

17. Python for you and me 0.2

18. Problem Solving with Algorithms and Data Structures using Python

19. The Art and Craft of Programming Python Edition

20. Python Programming

Python编程实践

Python学习手册 第x版

Python标准库

Python Cook Book(http://wiki.woodpecker.org.cn/moin/PyCookbook#head-46f748fbcc7334428c9de66085983ae69a4e8494)

如何入门

http://blog.csdn.net/wklken/article/details/7907560

http://timgolden.me.uk/python/

Copy and DeepCopy

importcopy

al= [[1],[2],[3]]

bl=copy.copy(al)

cl=copy.deepcopy(al)print "before=>"

print al #[[1], [2], [3]]

print bl #[[1], [2], [3]]

print cl #[[1], [2], [3]]

al[0][0]=0

al[1] =Noneprint "after=>"

print al #[[0], None, [3]]

print bl #[[0], [2], [3]]

print cl #[[1], [2], [3]]

#---------------------------------------------

importcopy

al= [1,2,3]

bl=copy.copy(al)

cl=copy.deepcopy(al)print "before=>"

print al #[[1], [2], [3]]

print bl #[[1], [2], [3]]

print cl #[[1], [2], [3]]

al[0]=0

al[1] =Noneprint "after=>"

print al #[0, None, 3]

print bl #[1, 2, 3]

print cl #[1, 2, 3]

Send Email

importsmtplibfrom email.mime.text importMIMEText

mailto_list= ['yaoyansi@aliyun.com']

mail_user= "yaoyansi"mail_postfix= "aliyun.com"

defsend_mail(to_list,sub,content):

me="hello"+""msg= MIMEText(content,_subtype='plain',_charset='gb2312')

msg['Subject'] =sub

msg['From'] =me

msg['To'] = ";".join(to_list)try:

server= smtplib.SMTP('localhost')

server.sendmail(me, to_list, msg.as_string())

server.close()returnTrueexceptException, e:printstr(e)returnFalseif __name__ == '__main__':if send_mail(mailto_list,"hello","hello world!"):print "good"

else:print "bad"

View Code

- function trace

def flog(format, *params):print("mytest:"+format %params)defmyfunction(a, b)

flog("%s %s", sys._getframe().f_code.co_name, locals())pass

- replace '\' with '/':

full_path = os.path.realpath(__file__);

full_path = full_path.replace('\\','/')

http://www.pythonscripting.com

A Brief Introduction to Python with Only One Figure

20 of the Best Free Python Books

1. Think Python

2. Invent Your Own Computer Games with Python

3. Snake Wrangling for Kids

4. Learn Python the Hard Way, 2nd Edition

5. Natural Language Processing with Python

6. Building Skills in Python

7. Dive into Python

8. Text Processing in Python

9. The Standard Python Library   *

10. The Definitive Guide to Pylons

11. Making Games with Python & Pygame

12. Python Module of the Week

14. Think Complexity

15. Data Structures and Algorithms with Object-Oriented Design Patterns in Python

16. Programming Computer Vision with Python

17. Python for you and me 0.2

18. Problem Solving with Algorithms and Data Structures using Python

19. The Art and Craft of Programming Python Edition

20. Python Programming

Python编程实践

Python学习手册 第x版

Python标准库

Python Cook Book(http://wiki.woodpecker.org.cn/moin/PyCookbook#head-46f748fbcc7334428c9de66085983ae69a4e8494)

如何入门

http://blog.csdn.net/wklken/article/details/7907560

http://timgolden.me.uk/python/

Copy and DeepCopy

importcopy

al= [[1],[2],[3]]

bl=copy.copy(al)

cl=copy.deepcopy(al)print "before=>"

print al #[[1], [2], [3]]

print bl #[[1], [2], [3]]

print cl #[[1], [2], [3]]

al[0][0]=0

al[1] =Noneprint "after=>"

print al #[[0], None, [3]]

print bl #[[0], [2], [3]]

print cl #[[1], [2], [3]]

#---------------------------------------------

importcopy

al= [1,2,3]

bl=copy.copy(al)

cl=copy.deepcopy(al)print "before=>"

print al #[[1], [2], [3]]

print bl #[[1], [2], [3]]

print cl #[[1], [2], [3]]

al[0]=0

al[1] =Noneprint "after=>"

print al #[0, None, 3]

print bl #[1, 2, 3]

print cl #[1, 2, 3]

Send Email

View Code

importre

str= r'

'p= re.compile(r'<.>')print p.match(str).group(0) #

print p.match(str).span() #(0, 6)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值