上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 32 下一页
摘要: Python内置了一些非常有趣但非常有用的函数,充分体现了Python的语言魅力! filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)返回: >>> def f(x): return x % 2 != 0 and x % 3 != 0 >>> filter(f, range(2, 25)) [5, 7, 11, 13, 17, 19, 23] >>> def f(x) 阅读全文
posted @ 2012-12-06 17:43 garfieldtom 阅读(743) 评论(0) 推荐(0)
摘要: ipython是一个很不错的调试工具,多谢园友zhuangzhuang1988提示。在Ubuntu下,安装ipython很简单:$sudo apt-get install ipythonUbuntu默认的python为2,所以如果要使用ipython3需要运行$sudo apt-get install ipython3如果想要使用ipython-qt,对于python2而言可以直接在软件中心中安装(当然,ipython也可以),对于ipyhon3-qt,则要麻烦一些。$sudo apt-get source python-slip$sudo apt-get python-qt4然后对于新下载的 阅读全文
posted @ 2012-12-06 14:42 garfieldtom 阅读(17787) 评论(0) 推荐(0)
摘要: 直接上代码吧,比较简单:#-*- encoding:utf-8 -*-'''自动下载壁纸,太平洋电脑网壁纸,http://wallpaper.pconline.com.cnBy garfieldtom,2012python ver:python 3感谢 枫叶饭团 提供解答,软件取回内容有压缩'''import re,urllib.requestimport gzip#获得页面内容def downwallpapers(url): urlcontent=geturlcontent(url) imglist=getimglist(urlcontent) 阅读全文
posted @ 2012-12-04 20:22 garfieldtom 阅读(1115) 评论(0) 推荐(1)
摘要: (参考python CookBook)直接上代码:#-*-coding:utf-8-*-'''简短地生成随机密码,包括大小写字母、数字,可以指定密码长度'''#生成随机密码fromrandomimportchoiceimportstring#python3中为string.ascii_letters,而python2下则可以使用string.letters和string.ascii_lettersdefGenPassword(length=8,chars=string.ascii_letters+string.digits):return' 阅读全文
posted @ 2012-12-03 19:57 garfieldtom 阅读(9966) 评论(0) 推荐(0)
摘要: 简单记录一下,git讲解很多,这里记录一下大体步骤。 1.首先在github.com上申请一个空间,然后在本机建立一个目录:mkdir gittest2.在该目录中建立一个文件:touch README.md3.初始化版本库 git init 4.增加文件到版本库 git add README.md 5.提交更改 git commit -m "first commit" 6.增加远程库 git remote add origin https://github.com/garfieldtom/python.git 7.提交到远程库 (增加到远程库完毕后以后有更改直接执行提交到 阅读全文
posted @ 2012-12-03 19:30 garfieldtom 阅读(329) 评论(1) 推荐(0)
摘要: 如果想查看某个模块提供了哪些函数等,我们可以进入python控制台,然后导入模块,再使用help(模块名)来查看这个模块的功能有哪些。以string模块为例:>>>importstring>>>help(string)Helponmodulestring:NAMEstring-Acollectionofstringoperations(mostarenolongerused).FILE/usr/lib/python2.7/string.pyMODULEDOCShttp://docs.python.org/library/stringDESCRIPTIONWa 阅读全文
posted @ 2012-12-03 17:01 garfieldtom 阅读(59341) 评论(2) 推荐(3)
摘要: 安装git和openssh: $ sudo apt-get install git-core openssh-server openssh-client新加用户git,该用户将作为所有代码仓库和用户权限的管理者: $ sudo useradd -m git为git设置密码: $ sudo password git建立一个git仓库的存储点,我放在了/opt/git下,并且设置git以外的用户对此目录无任何权限: $ mkdir /opt/git$ sudo chow git:git /opt/git$ sudo chmod 700 /opt/git初始化一下服务器的git用户,为了安装gito 阅读全文
posted @ 2012-12-01 10:41 garfieldtom 阅读(411) 评论(0) 推荐(0)
摘要: Ubuntu 12.04安装 deb包时报告内部错误,很多包都是这样,上网搜索了解决办法:1、更新软件中心sudo apt-get upgrade software-center2、然后安装lzmasudo apt-get install lzma lzma-dev执行上述步骤 然后重新安装即可执行完后再安装还有报告这个错误。后来又执行了一次,可以了,奇怪,第一次执行也没有报告错误,第二次执行也没有提示更新内容。 阅读全文
posted @ 2012-11-21 16:30 garfieldtom 阅读(1194) 评论(0) 推荐(0)
摘要: Ubuntu 12.04下Ulipad的安装来源:Linux社区 作者:nicoliuUlipad – 超级好用的国产Python IDE,开发者是limodou。此IDE本身就是用Python + wxPython编写的。在Windows系统中一直使用Ulipad,最近想在Linux(Ubuntu 12.04)进行学习和实验,安装过程还是有些区别的。 在安装ulipad之前,先安装一个超级好用的Python的交互式Shell--iPython。iPython功能很强大,她支持语法高亮/自动完成/代码调试/对象自省,支持Bash Shell命令,内置了很多很有用的功能和函式。 $ s... 阅读全文
posted @ 2012-11-18 21:22 garfieldtom 阅读(309) 评论(0) 推荐(0)
摘要: 在Dreamwaver中写了个PHP文件,使用的是utf-8编码,然后到EclipsePHP(Eclipse)中打开,汉字显示为乱码。解决办法1:修改工作空间的编码格式:Window->Preferences->General->Workspace->Text file Encoding解决办法2:修改单个工程的编码格式:右击工程,在弹出的菜单中选择最后一项“Properties” ,在打开的新窗口左边的菜单树中选择 Info(即第一个),然后在右面找到 Text file encoding ,选择 “other”,在下拉框中选择需要的编码方式。解决办法3:修改一类文件 阅读全文
posted @ 2012-11-14 11:39 garfieldtom 阅读(8765) 评论(1) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 32 下一页