
#!/usr/bin/env python\x0d\x0a#注意上面这一行必须是第一行顶头写。\x0d\x0a# python file example. \x0d\x0a# assume we name this file as "hello.py"\x0d\x0a# use shell command "chmod +x hello.py" to make this file executable. \x0d\x0a# then you are able to run it by typing "./hello.py"\x0d\x0aprint "Hello this is from python!"有两种方式:\x0d\x0a1、直接使用pythonxxxx.py
执行。其中python可以写成python的绝对路径。使用whichpython进行查询。\x0d\x0a2、在
文件的头部(第一行)写上#!/usr/bin/python2.7,这个地方使用python的绝对路径,就是上面用whichpython查询来的结果。然后在外面就可以使用./xxx.py执行了。\x0d\x0a\x0d\x0a因为在linux中,python啊shell这些程序都是普通的文本格式,都需要一种程序去解释执行它。要么调用的时候
指定,要么在文件头指定。
评论列表(0条)