我尝试将我的项目转换为python3。
我的服务器脚本是server.py:
#!/usr/bin/env python
#-*-coding:utf8-*-
import http.server
import os, sys
server = http.server.HTTPServer
handler = http.server.CGIHTTPRequestHandler
server_address = ("", 8080)
#handler.cgi_directories = [""]
httpd = server(server_address, handler)
httpd.serve_forever()但当我尝试时:
import urllib.request, urllib.parse, urllib.error我在python3 ./server.py的终端中得到了这个:
import urllib.request, urllib.parse, urllib.error
ImportError: No module named request
127.0.0.1 - - [18/Sep/2016 22:47:18] CGI script exit status 0x100我该怎么做呢?
发布于 2016-09-19 00:11:10
您的建议建议代码应该由Python二进制文件运行,python二进制文件历史上与Python2.x版本相关。
只需将第一行更改为:
#!/usr/bin/env python3https://stackoverflow.com/questions/39559384
复制相似问题