`
conjohn668
  • 浏览: 18474 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论
文章列表
Python中的splitlines用来分割行。当传入的参数为True时,表示保留换行符 \n。通过下面的例子就很明白了 mulLine = """Hello!!! Wellcome to Python's world! There are a lot of interesting things! Enjoy yourself. Thank you!""" print ''.join(mulLine.splitlines()) print '------------' print ''.join(mulLine.spli ...
December 7, 2005 | Fredrik Lundh Python’s getattr function is used to fetch an attribute from an object, using a string object instead of an identifier to identify the attribute. In other words, the following two statements are equivalent: value = obj.attribute value = getattr(obj, "attribute& ...
在运行程序时,可能需要根据不同的条件,输入不同的命令行选项来实现不同的功能。目前有短选项和长选项两种格式。短选项格式为"-"加上单个字母选项;长选项为"--"加上一个单词。长格式是在Linux下引入的。许多Linux程序都支持这两种格式。在Python中提供了getopt模块很好的实现了对这两种用法的支持,而且使用简单。 取得命令行参数   在使用之前,首先要取得命令行参数。使用sys模块可以得到命令行参数。 import sys print sys.argv   然后在命令行下敲入任意的参数,如: python get.py -o t --help ...
1、 准备知识: 在python里,字典dictionary是内置的数据类型,是个无序的存储结构,每一元素是key-value对: 如:dict = {‘username’:‘password’,‘database’:‘master’},其中‘username’和‘database’是key,而‘password’和‘master’是value,可以通过d[key]获得对应值value的引用,但是不能通过value得到key。 对于dictionnary,需知道以下几点注意事项: a、 dictionary 的 key 是大小写敏感的; b、 一个dictionary中不能有重复的 k ...
sudo ln -s /usr/local/bin/python /usr/bin/python sudo ln -s /usr/local/bin/pydoc /usr/bin/pydoc sudo ln -s /usr/local/bin/pythonw /usr/bin/pythonw
Global site tag (gtag.js) - Google Analytics