Python学习笔记三(Python程序升级安装及其Tab自动补齐功能)

简介:

 Linux系统自带的python版本通常都比较低,可以在python官方网站(http://www.python.org/download/)下载最新源码包,然后进行升级安装。
1.下载python源码包。

1
wget http: / / www.python.org / ftp / python / 2.7 . 5 / Python - 2.7 . 5.tar .bz2

2.解压,编译安装。

1
2
3
4
tar  - jxvf Python - 2.7 . 5.tar .bz2
cd Python - 2.7 . 5
. / configure  - - prefix = / usr / local / python2. 7.5
make && make install

3.指定新python安装路径。

1
2
3
4
5
6
7
8
python  - #查看系统之前python版本
Python  2.4 . 3
which python  #查看之前系统python可执行文件的路径
/ usr / bin / python
mv  / usr / bin / python  / usr / bin / python.bak
ln  - / usr / local / python2. 7.5 / bin / python  / usr / bin / python  #指定新版本路径
python  - V
Python  2.7 . 5

 Python升级安装就这么简单,下面介绍标准python shell的自动补齐功能,如果在编译时增加了readline特性,将具有tab自动完成功能,对python编程或者初学者都有很大的帮助。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
python
Python  2.7 . 5  (default, Jun  13  2013 15 : 08 : 30 )
[GCC  4.1 . 2  20080704  (Red Hat  4.1 . 2 - 46 )] on linux2
Type  "help" "copyright" "credits"  or  "license"  for  more information.
>>>  import  rlcompleter,readline
>>> readline.parse_and_bind( 'tab: complete' )
>>>  import  time
>>> time.
time.__class__(         time.__reduce__(        time.daylight
time.__delattr__(       time.__reduce_ex__(     time.gmtime(
time.__dict__           time.__repr__(          time.localtime(
time.__doc__            time.__setattr__(       time.mktime(
time.__file__           time.__sizeof__(        time.sleep(
time.__format__(        time.__str__(           time.strftime(
time.__getattribute__(  time.__subclasshook__(  time.strptime(
time.__hash__(          time.accept2dyear       time.struct_time(
time.__init__(          time.altzone            time.time(
time.__name__           time.asctime(           time.timezone
time.__new__(           time.clock(             time.tzname
time.__package__        time.ctime(             time.tzset(

 有关python升级安装和Tab用法就学习到这里,接下来学习python模块。

     备注:python交互式模式里面不能按回格键(Backspace)解决版本, yum install readline-devel 然后重新编译安装即可。










本文转自 sfzhang 51CTO博客,原文链接:http://blog.51cto.com/sfzhang88/1221258,如需转载请自行联系原作者

目录
相关文章
|
11月前
|
Linux 计算机视觉 C++
【解决方案】Building wheel for opencv-python:安装卡顿的原因与解决方案
当你安装OpenCV时,命令行停在Building wheel for opencv-python (PEP 517) ... -似乎卡住了。这并非程序假死,而是其编译耗时巨大。本文将揭示原因,并提供优化安装体验的实用方法。
1286 88
|
8月前
|
监控 安全 程序员
Python日志模块配置:从print到logging的优雅升级指南
从 `print` 到 `logging` 是 Python 开发的必经之路。`print` 调试简单却难维护,日志混乱、无法分级、缺乏上下文;而 `logging` 支持级别控制、多输出、结构化记录,助力项目可维护性升级。本文详解痛点、优势、迁移方案与最佳实践,助你构建专业日志系统,让程序“有记忆”。
696 0
|
9月前
|
设计模式 缓存 监控
Python装饰器:优雅增强函数功能
Python装饰器:优雅增强函数功能
372 101
|
9月前
|
缓存 测试技术 Python
Python装饰器:优雅地增强函数功能
Python装饰器:优雅地增强函数功能
306 99
|
9月前
|
存储 缓存 测试技术
Python装饰器:优雅地增强函数功能
Python装饰器:优雅地增强函数功能
511 98
|
9月前
|
缓存 Python
Python中的装饰器:优雅地增强函数功能
Python中的装饰器:优雅地增强函数功能
|
10月前
|
人工智能 Linux 开发工具
Python从零到一:手把手带你写出第一个实用程序
Python语法简洁易懂,适合编程新手入门。它广泛应用于人工智能、自动化办公、Web开发等领域。学习Python可快速搭建项目,拥有丰富库支持和强大社区资源。通过本教程,你将掌握基础语法、环境搭建、程序逻辑控制及实战项目开发,开启编程之旅。
1313 0
|
9月前
|
人工智能 数据安全/隐私保护 异构计算
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
1437 8
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
|
9月前
|
设计模式 决策智能 Python
Python条件控制:让程序学会"思考"的魔法
本文深入浅出地讲解Python条件控制,从基础if语句到多分支、嵌套结构,再到简洁的三元表达式与Python 3.10新增的match-case模式匹配,结合电商折扣、会员等级、ATM系统等实战案例,全面掌握程序“智能决策”的核心逻辑。
572 0

推荐镜像

更多