脚本语言的解释器有什么用
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']

。

浙公网安备 33010602011771号