1.如果想给函数写文档,让后面使用函数的人能理解的话,可以加一些注释(#开头)2. 在函数的开头写下字符串,会作为函数的一部分进行存储,称为文档字符串例如:def square(x): 'calculates the squareof the number x.' return x*x文档字符串的访问方式:>>square.__doc__'calculate...【阅读全文】
For more than a decade, no single issue has caused more frustration or curiosity for Python novices and experts alike than the Global Interpreter Lock.An Open QuestionEvery field has one. A problem that has been written off as too difficult, too time consuming. Merely mentioning an attempt...【阅读全文】
1.in 和 not in区别点击(此处)折叠或打开[root@oracle11g home]# ipython/usr/lib/python2.6/site-packages/IPython/Magic.py:38: DeprecationWarning: the sets module is deprecated from sets import SetPython 2.6.6 (r266:84292, M...【阅读全文】
[root@oracle11g home]# cat pysysinfo_func.py #!/usr/bin/env python#A System Information Gathering Scriptimport subprocess#Command 1def uname_func():uname = "uname"uname_arg = "-a"print "Gathering system information with %s command:\n" %unamesubprocess.call([uname,uname_arg])#Com...【阅读全文】
how to change the default python version?I'm wanting to use some newer software that requires Python 2.6, and we currently have both 2.4and 2.6 installed on our dedicated CentOS server, which looks like this:$ which python /usr/local/bin/python$ which python2.6 /usr/bin/python2.6 $ which ...【阅读全文】
1.从用户那里得到输入最容易的方法就是使用raw_input函数,[root@oracle11g ~]# pythonPython 2.6.6 (r266:84292, May 1 2012, 13:52:17) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> user = raw_input('Enter login nam...【阅读全文】