一.安装ipython
1.升级pyton到2.7.0以上
[root@python ~]# yum install gcc gcc-c++ make -y [root@python ~]# wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2 [root@python ~]# tar xf Python-2.7.5.tar.bz2 [root@python ~]# cd Python-2.7.5 [root@python Python-2.7.5]# ./configure --prefix=/usr/local/python2.7.5 [root@python Python-2.7.5]# make && make install [root@python Python-2.7.5]# mv /usr/bin/python /usr/bin/python2.6.6.old [root@python ~]# ln -s /usr/local/python2.7.5/bin/python2.7 /usr/bin/python #修改yum配置 [root@python ~]# vim /usr/bin/yum #!/usr/bin/python2.6 #改为python2.6 [root@python ~]# 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
[root@python ~]# yum install zlib-devel openssl-devel sqlite-devel -y [root@python ~]# wget https://pypi.python.org/packages/source/i/ipython/ipython-2.3.1.tar.gz#md5=2b7085525dac11190bfb45bb8ec8dcbf --no-check-certificate [root@python ~]# tar xf ipython-2.3.1.tar.gz [root@python ~]# cd ipython-2.3.1 [root@python ipython-2.3.1]# python setup.py install [root@python ipython-2.3.1]# ln -s /usr/local/python2.7.5/bin/ipython /usr/bin/ [root@python ipython-2.3.1]# which ipython /usr/bin/ipython [root@python ~]# 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
[root@python day1]# cat raw_input.py #!/usr/bin/env python name = raw_input(‘Please input your name: ‘) print ‘your name is %s‘ % name #执行脚本 [root@python day1]# python raw_input.py Please input your name: tom your name is tom
本文出自 “ly36843运维” 博客,请务必保留此出处http://ly36843.blog.51cto.com/3120113/1672806
原文地址:http://ly36843.blog.51cto.com/3120113/1672806