linux操作系统安装python3
首先是下载python3,现在的最高版本是3.1.1
for linux。
我的放置路径是/home/python下放置Python-3.1.1.tgz,执行以下系列操作:
1.解压:tar zxvf Python-3.1.1.tgz----生成解压包Python-3.1.1
2.转换到Python-3.1.1路径下,执行./configure
3.make
4.make install
在rehl5中已经默认安装了python2.4,所以要做如下操作:
#cd /usr/bin
#ll |grep python //查看该目录下python
#rm -rf python
#ln -s PREFIX/
Python-3.1.1/python ./python //PREFIX为你解压python的目录
#python
检测改正之后的python版本
相关文档:
模块这东西好像没什么好讲的,无非是保存一份文件,然后在另一份文件中用import 和from ** import **(*)就行了。
这一章主要讲到了细节,导入模块Python里面是什么处理的,import 和 from ** import **有什么不一样。还有就是增加了reload()这个函数的使用说明。
以前看到哪里说尽量使用import而不要使用from ** import * ......
# 027
toolName = 'Google'
if toolName.startswith('Go'):
print 'The tool\'s name starts with \"Go\".'
if 'oo' in toolName:
print 'The tool\'s name contains the stirng "oo".'
print toolName.find('gl') # 返回首次出现“gl”字符串的索引
if toolName.find('Baidu ......
源代码下载:下载地址在这里
# 029
aFile = file(r'C:\in.txt', 'r')
while True:
line = aFile.readline()
if len(line) == 0:
break
# end of if
print line,
# end of while
aFile.close()
output:
>>>
This is the first line.
This is the second line.
This is ......
源代码下载:下载地址在这里
# 035
class Person:
population = 0 #这个变量是属于整个类的
def __init__(self, name):
self.name = name
print '初始化 %s' % self.name
Person.population += 1
# end of def
def __del__(self):
print '%s says bye.' % self. ......