![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
sclxf
大部分文章都是本人发呆之中,左手ctrl c, 右手ctrl v生产出来的。包括这句话。如有侵权,请告知。贵有恒,何以三更眠五更起;最无益,最怕一日曝十日寒。做事提前,不要推后。进步每一天。I Lovin Swimming
展开
-
Python Self
类的方法与普通的函数只有一个特别的区别——它们必须有一个额外的第一个参数名称,但是在调用这个方法的时候你不为这个参数赋值,Python会提供这个值。这个特别的变量指对象本身,按照惯例它的名称是self。虽然你可以给这个参数任何名称,但是 强烈建议 你使用self这个名称——其他名称都是不赞成你使用的。使用一个标准的名称有很多优点——你的程序读者可以迅速识别它,如果使用self的话,还有转载 2008-11-08 21:19:00 · 604 阅读 · 0 评论 -
转载:python中字符串的最后一个字符是斜杠会导致出错
http://againinput4.blog.163.com/blog/static/1727994912011111761152681/转载 2012-03-22 21:38:39 · 1995 阅读 · 0 评论 -
Python 杂感
Python确实比较好用,简洁高效,不用像c,c++这类强定义类型语言那样抠的恨死。而且有些任务用脚本语言来实现,比动不动就请出c,c++这类火力强悍的工具更省事。可我总是对python 很迷糊,尤其是对其环境设置有种心虚和恐惧。一年前用过Python Image Library,使用其中的Pilconvert.py进行图片格式转换,将jpg转换为pgm格式。当时是在linux平台原创 2010-04-01 22:06:00 · 851 阅读 · 1 评论 -
python 写文件
用python写文件,偷了个懒,直接写f = file(name,a)f.write(aaa)......被提示错误,str object not callable在前面加上初始化f = open(name,a)f.write(aaa)....错误不再。原创 2010-04-02 10:48:00 · 687 阅读 · 0 评论 -
Reading and writing .mat files with Python
from: http://www.janeriksolem.net/2009/05/reading-and-writing-mat-files-with.htmlReading and writing .mat files with PythonIf you have some old data, or find some interesting data转载 2010-03-29 20:14:00 · 1371 阅读 · 0 评论 -
Python相关模块学习1 处理文件名模块glob
>>> import glob>>> dir(glob)[__all__, __builtins__, __doc__, __file__, __name__, fnmatch, glob, glob1, has_magic, magic_check, os, re]>>> help(glob)Help on module glob:NAME转载 2009-03-07 19:07:00 · 967 阅读 · 0 评论 -
python IDLE
六、使用IDLE的调试器软件开发过程中,总免不了这样或那样的错误,其中有语法方面的,也有逻辑方面的。对于语法错误,Python解释器能很容易的检测出来,这时它会停止程序的运行并给出错误提示。对于逻辑错误,解释器就鞭长莫及了,这时程序会一直执行下去,但是得到的运行结果却是错误的。所以,我们常常需要对程序进行调试。最简单的调试方法是直接显示程序数据,例如可以在某些关键位置用print语句显示出变量转载 2009-03-07 09:32:00 · 1034 阅读 · 0 评论 -
python Dictionary
字典(Dictionary)是一种映射结构的数据类型,由无序的“键-值对”组成。字典的键必须是不可改变的类型,如:字符串,数字,tuple;值可以为任何python数据类型。1、新建字典>>> dict1={} #建立一个空字典>>> type(dict1)2、增加字典元素:两种方法>>> dict1[a]=1 #第一种>>> dict1{a: 1}#第二种:setdefa转载 2009-03-07 09:19:00 · 1151 阅读 · 0 评论 -
Python Set
Set SemanticsA set is, perhaps the simplest possible container, since it contains objects in no particular order with no particular identification. Objects stand for themselves. With a sequence,转载 2009-03-07 09:00:00 · 1015 阅读 · 0 评论 -
[Python]随机数与随机字符串
随机整数:>>> import random>>> random.randint(0,99)21随机选取0到100间的偶数:>>> import random>>> random.randrange(0, 101, 2)42随机浮点数:>>> import random>>> random.random() 0.85415370477785668>>> random.uniform(1, 1转载 2009-03-07 09:20:00 · 1486 阅读 · 0 评论 -
Tutorial on Threads Programming with Python
heather.cs.ucdavis.edu/~matloff/Python/PyThreads.pdf转载 2008-11-18 21:26:00 · 531 阅读 · 0 评论 -
2.3 Built-in Exceptions
Exceptions should be class objects. The exceptions are defined in the module exceptions. This module never needs to be imported explicitly: the exceptions are provided in the built-in namespace as转载 2008-11-18 21:18:00 · 802 阅读 · 0 评论 -
Simplified Exception Identification in Python
Using functions and exception pattern dictionaries to simplify error recovery. One of the features that makes Python a great programming language is exceptions for error handling. Except转载 2008-11-18 21:14:00 · 929 阅读 · 0 评论 -
python模块之HTMLParser
HTMLParser是python用来解析html的模块。它可以分析出html里面的标签、数据等等,是一种处理html的简便途径。HTMLParser采用的是一种事件驱动的模式,当HTMLParser找到一个特定的标记时,它会去调用一个用户定义的函数,以此来通知程序处理。它主要的用户回调函数的命名都是以handler_开头的,都是HTMLParser的成员函数。当我们使用时,就从HTMLPars转载 2008-11-08 22:20:00 · 908 阅读 · 0 评论 -
Digits of PI (Part 2)
https://pythonadventures.wordpress.com/2012/04/13/digits-of-pi-part-2/第二种方法,与原贴稍微有点出入,import mpmathmpmath.mp.dps = 1000+mpmath.mp.pimpf('3.141592653589793238462643383279502884197转载 2016-08-26 04:38:53 · 985 阅读 · 0 评论