脚本语言的解释器有什么用

 

001、脚本解释器用于说明程序执行的方式。

复制代码
[root@pc1 test1]# ls             ## 两个测试脚本, test02.script 相比于test01.script多了指定python解释器的语句 #!/usr/bin/env python
test01.script  test02.script
[root@pc1 test1]# cat test01.script ##测试程序test01.script,无指定python解释器的语句

list1 = ["aa", "bb", "cc", "dd"]
print(list1)
[root@pc1 test1]# cat test02.script ## 测试程序 test02.script,有指定python解释器的语句
#!/usr/bin/env python
# -*- coding: utf-8 -*-

list1 = ["aa", "bb", "cc", "dd"]
print(list1)
[root@pc1 test1]# chmod +x test01.script test02.script   ## 给两个测试程序执行的权限
[root@pc1 test1]# ls
test01.script  test02.script
[root@pc1 test1]# ./test01.script   ## test01.script,不可以正常执行,模式的是bash解释器
./test01.script: line 2: list1: command not found
./test01.script: line 3: syntax error near unexpected token `list1'
./test01.script: line 3: `print(list1)'
[root@pc1 test1]# ./test02.script   ## test02.script,可以正常执行,因为#!/usr/bin/env python执行了python解释器,则按照python解释器执行
['aa', 'bb', 'cc', 'dd']
复制代码

 

 。

 

posted @   小鲨鱼2018  阅读(18)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-03-08 samtools 统计重测序数据深度 depth、depth -a、depth -aa的联系与区别
2021-03-08 python中如何获取函数文档
2021-03-08 python中写一个求阶乘的函数
2021-03-08 python中写一个求阶乘的函数
2021-03-08 python中map()内置函数
2021-03-08 python中filter关键字
2021-03-08 python中lambda关键字创建匿名函数
点击右上角即可分享
微信分享提示