python解释器
来源:互联网 发布:软件系统安装调试方案 编辑:程序博客网 时间:2024/05/13 07:20
在linux/unix系统能够上默认都安装的是python2.x的版本,并且yum也需要;但是我们可以将新安装的python3单独安装,并设置环境变量即可。
比如在编译安装时候./configure --prefix=/usr/local/python36,然后设置环境变量PATH=$PATH:/usr/local/python36/bin/python3即可
另外我们可以将原来的python2.X的默认软连接修改掉,直接使用,参照http://blog.csdn.net/jc_benben/article/details/26574465
交互式
直接在命令行下输入python命令启动python解释器,然后输入相应的命令即可执行;运行多行时,一个空行默认是结束符
脚本编程
第一种,这种可以在windows,linux/unix下执行
将命令放到脚本中,比如print('hello,world!')放到脚本,hello.py中
使用python hello.py执行
[root@centos7 ~]# python hello.py hello,world[root@centos7 ~]# cat hello.py print('hello,world')另外一种,在linux/unix系统上,可以在头部添加
#! /usr/bin/env python
进而让脚本想shell一样直接执行,也可以添加#! /usr/bin/python
修改权限,执行
[root@centos7 ~]# cat hello.py #! /usr/bin/env pythonprint('hello,world')[root@centos7 ~]# chmod +x hello.py [root@centos7 ~]# ./hello.py hello,world说明:
#! /usr/bin/env python
这种写法在机器上安装了多个版本时候,将会在环境变量中获取第一个python来执行脚本,如果这时候你又配置了虚拟环境的话,那么这样写可以保证脚本会使用你虚拟环境中的 python 来执行#! /usr/bin/python
表示使用/usr/bin/python这个来执行脚本,可以移植性差 0 0
- 配置Python解释器
- 解释器模式(python)
- python 解释器
- Python解释器
- Python解释器
- 安装python解释器
- python调用解释器
- python解释器
- Python解释器
- python指定解释器
- Python解释器
- python交互式解释器
- 使用python解释器
- Python解释器
- Python---- 编译器,解释器
- Python-解释器
- Python解释器
- Python解释器
- ios应用推广策略
- Android 内存管理与gc 回收机制
- 猴子吃桃问题
- Android内存优化
- Listview item加载的过程
- python解释器
- C++中的单例模式
- oracle connect by 用法
- 【OpenCV】Mat转IpIImag*以及IpIImage*灰度化
- 从轻松筹两大模式看众筹如何才能更接地气
- 柴俊理金:米国遭袭皆大欢喜,静待黄金沥青反弹
- Http协议详解
- propertygrid easyui 的使用
- 测试,说句心里话