一.安装ipython
1.升级pyton到2.7.0以上
[[email protected] ~]# yum install gcc gcc-c++ make -y [[email protected] ~]# wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2 [[email protected] ~]# tar xf Python-2.7.5.tar.bz2 [[email protected] ~]# cd Python-2.7.5 [[email protected] Python-2.7.5]# ./configure --prefix=/usr/local/python2.7.5 [[email protected] Python-2.7.5]# make && make install [[email protected] Python-2.7.5]# mv /usr/bin/python /usr/bin/python2.6.6.old [[email protected] ~]# ln -s /usr/local/python2.7.5/bin/python2.7 /usr/bin/python #修改yum配置 [[email protected] ~]# vim /usr/bin/yum #!/usr/bin/python2.6 #改为python2.6 [[email protected] ~]# python Python 2.7.5 (default, Jul 10 2015, 10:34:08) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
2.安装ipython
[[email protected] ~]# yum install zlib-devel openssl-devel sqlite-devel -y [[email protected] ~]# wget https://pypi.python.org/packages/source/i/ipython/ipython-2.3.1.tar.gz#md5=2b7085525dac11190bfb45bb8ec8dcbf --no-check-certificate [[email protected] ~]# tar xf ipython-2.3.1.tar.gz [[email protected] ~]# cd ipython-2.3.1 [[email protected] ipython-2.3.1]# python setup.py install [[email protected] ipython-2.3.1]# ln -s /usr/local/python2.7.5/bin/ipython /usr/bin/ [[email protected] ipython-2.3.1]# which ipython /usr/bin/ipython [[email protected] ~]# ipython Python 2.7.5 (default, Jul 10 2015, 10:34:08) Type "copyright", "credits" or "license" for more information. IPython 2.3.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython‘s features. %quickref -> Quick reference. help -> Python‘s own help system. object? -> Details about ‘object‘, use ‘object??‘ for extra details. In [1]:
二.用户交互raw_iput
[[email protected] day1]# cat raw_input.py #!/usr/bin/env python name = raw_input(‘Please input your name: ‘) print ‘your name is %s‘ % name #执行脚本 [[email protected] day1]# python raw_input.py Please input your name: tom your name is tom
时间: 2024-10-11 19:48:36