一般在python的文件头部加上:
#!/usr/bin/env python
就可以直接运行,也才可以在以CGI的方式运行
我就是要以CGI的方式运行,但我的一直运行出错,表现为:
$python -m CGIHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
192.168.91.1 - - [20/Jun/2012 20:00:16] "GET /cgi-bin/index.py?s=11 HTTP/1.1" 200 -
: No such file or directory
192.168.91.1 - - [20/Jun/2012 20:00:16] CGI script exit status 0x7f00
后面看了百度好多地方,包括google,也没找到原因,直到看到这个:
http://hgoldfish.mysmth.net/2008/08/09/%E8%BF%90%E8%A1%8Clinux%E7%9A%84%E8%84%9A%E6%9C%AC%E8%80%81%E6%98%AF%E5%87%BA%E7%8E%B0-no-such-file-or-directory%E9%94%99%E8%AF%AF/
才搞定
原因居然是因为用的是windows格式的换行符,而不是unix格式的,所以。。。改成unix格式即可
分享到:
相关推荐
官方datax只能使用python2.7版本,是因为语法问题,下载这个文件解压放置在datax/bin目录,环境切换到py3即可启动,亲测可用
/usr/bin/env python 这种⽤法是为了防⽌操作系统⽤户没有将 python 装在默认的 /usr/bin 路径⾥。当系统看到这⼀⾏的时候,⾸先 会到 env 设置⾥查找 python 的安装路径,再调⽤对应路径下的解释器程序完成操作。 #...
/usr/bin/env python 这种⽤法是为了防⽌操作系统⽤户没有将 python 装在默认的 /usr/bin 路径⾥。当系统看到这⼀⾏的时候,⾸先 会到 env 设置⾥查找 python 的安装路径,再调⽤对应路径下的解释器程序完成操作。 #...
/usr/bin/env python 这种用法是为了防止操作系统用户没有将 python 装在默认的 /usr/bin 路径里。当系统看到这一行的时候,首先会到 env 设置里查找 python 的安装路径,再调用对应路径下的解释器程序完成操作。 #!...
/usr/bin/env python 这种⽤法是为了防⽌操作系统⽤户没有将 python 装在默认的 /usr/bin 路径⾥。当系统看到这⼀⾏的时候,⾸先 会到 env 设置⾥查找 python 的安装路径,再调⽤对应路径下的解释器程序完成操作。 #...
Python用WMI模块获取Windows.../usr/bin/env python # -*- coding: utf- -*- #http://www.cnblogs.com/liu-ke/ import wmi import os import sys import platform import time def sys_version(): c = wmi.WMI
/usr/bin/env python #-*-coding:utf-8-*- import sys import struct#将字符串打包为二进制流进行网络传输 import select# import signal#用于捕获中断信号 import cPickle#将python对象进行序列化:dumps将python...
/usr/bin/env python # -*- coding: utf-8 -*- # 2/10/16 base trans. wrote by srcdog on 20th, April, 2009 # ld elements in base 2, 10, 16. import os,sys # global definition # base = [0, 1, 2, 3,
/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import urllib import urllib2 import string #########start 获取url的返回信息############ def jwkj_url_postget(url,vlaues): data = ...
本文实例讲述了Python使用爬虫抓取美女图片并.../usr/bin/env python # -*- coding: utf-8 -*- import os import urllib import urllib.request import re from urllib.error import URLError class QsSpider: def __
/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Seven' import math # 计算距离 def getDistance(latA, lonA, latB, lonB): ra = 6378140 # 赤道半径 rb = 6356755 # 极半径 flatten = (ra - rb) / ...
/usr/bin/env python # -*- coding: utf-8 -* import serial import serial.tools.list_ports port_list = list(serial.tools.list_ports.comports()) if len(port_list) <= 0: print The Serial port can't ...
/usr/bin/env python # -*- coding: utf-8 -*- from simple_export.example import test1 test1() example 方法名:write_excel_for_template 入参:value # {"sheet页名称": {}} 一级key需要跟sheet页相同 入...
/usr/bin/env python # -*- coding=utf-8 -*- import urllib2 url="https://www.baidu.com" req_header = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271...
/usr/bin/env python # encoding: utf-8 #字典去重小代码 import sys import os import platform try: pass except: print '''you have something wrong this is a simple jiaoben ''' sys.exit() why = 'why.txt...
/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/11/27 15:59 # @Desc : 定时任务,以需要的时间间隔执行某个命令 # @File : timedtask.py # @Software: PyCharm import time, os from monitorserver ...
/usr/bin/env python #coding: utf8 import getpass db = {} def newUser(): username = raw_input('username: ') if username in db: #添加打印颜色 print "\033[32;1m%s already exists![0m" % username else...
/usr/bin/env python # -*- coding: utf-8 -*- ”’ @Author:Quico Tomy @Function:Input a phone number and print by line @Demo Time:2015-3-16 ”’ numstr = raw_input(“Input number: “) num = list...
/usr/bin/env python # coding:UTF-8 @version: python3.x @author:曹新健 @contact: 617349013@qq.com @software: PyCharm @file: admin.py @time: 2018/9/11 10:14 import time class Admin(): def __init__...
/usr/bin/env python# -*- coding:utf-8 -*- #导入random和string模块import random, string def GenPassword(length): #随机出数字的个数 numOfNum = random.randint(1,length-1) numOfLetter = length – ...