python3在线解释器_Python3 解释器

Python3 解释器

阅读 (134) |

发布于 2020-05-11 18:42:13

Linux/Unix的系统上,一般默认的 python 版本为 2.x,我们可以将 python3.x 安装在 /usr/local/python3 目录中。

然后通过命令来启动python3

$ PATH=$PATH:/usr/local/python3/bin/python3 # 设置环境变量

$ python3 --version

Python 3.4.0

交互式编程

在命令行输入 python 来启动python解释器, 就可以进入到python的交互式编程环境

# python

Python 3.6.5 (default, Apr 9 2019, 17:44:18)

[GCC 4.8.2 20131212 (Red Hat 4.8.2-8)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> print("hello world")

hello world

>>> for i in range(3):

... print(i)

...

0

1

2

>>> istrue = True

>>> if istrue:

... print('yes')

...

yes

脚本式编程

vim test.py

#!/usr/bin/env python3

print("hello world!")

for i in range(3):

print(i)

istrue = True

if istrue:

print('yes')

然后通过解释器来执行

#python test.py

hello world!

0

1

2

yes

### 给脚本可执行权限

#chmod +x test.py

#./test.py

hello world!

0

1

2

yes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值