0

Python基础知识及常见问题

Posted by Alan on May 17, 2016 in Coding, FAQ |

Linux下安装IPython

CentOS下运行yum list | grep ipython查看安装包

python-ipython.noarch             0.13.2-7.el6                 @epel   
python-ipython-console.noarch     0.13.2-7.el6                 @epel   
python-ipython-gui.noarch         0.13.2-7.el6                 @epel   
python-ipython-notebook.noarch    0.13.2-7.el6                 @epel   
python-ipython-doc.noarch         0.13.2-7.el6                 epel    
python-ipython-tests.noarch       0.13.2-7.el6                 epel  

运行yum -y install python-ipython.noarch完成安装,进入IPython命令行输入ipython:

验证IPython的安装

Tcl/Tk不稳定报错

Mac上在Terminal中输入idle即可进入idle编辑器,但会发现如下警告:

WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.

打开上面这个网页按照指引进入http://www.activestate.com/activetcl/downloads下载最新版的TCL(8.5.*)进行安装即可

下载TCL

实现Tab auto complete

可以Python的库目录下(如/usr/lib/python2.7/site-packages)创建tab.py,然后在命令行中import tab.py再使用tab即可

注:在Python命令行中直接使用dir(变量)命令也可以查看适用的方法

import readline
import rlcompleter
if 'libedit' in readline.__doc__:
    readline.parse_and_bind("bind ^I rl_complete")
else:
    readline.parse_and_bind("tab: complete")

 

Tags: ,

Leave a Reply

Copyright © 2012-2018 记录点滴生活 | Alan Hou的个人博客 All rights reserved.