脚本语言的解释器有什么用
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']
。
分类:
linux shell
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!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关键字创建匿名函数