我正在学习 python 并且对 ctype 和 ctypes 感到困惑。在讲座中,讲师使用 ctype,我搜索了它,但只有 ctypes 模块结果。所以我不确定 ctype 和 ctypes 在 python 中是否相同。在官方文档中,我必须 import ctypes
,但是我没有导入它。
这是我的代码,
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import cgi
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
def do_POST(self):
try:
if self.path.endswith('/edit'):
ctype, pdict = cgi.parse_header(
self.headers.getheader('content-type')
)
if ctype=='multipart/form-data':
fields = cgi.parse_multipart(self.rfile, pdict)
messagecontent = fields.get('newRestaurantName')
restaurantIDPath = self.path.split("/")[2]
myRestaurantQuery= session.query(Restaurant).filter_by(
if=restaurantIDPath).one()
if myRestaurantQuery!=[]:
myRestaurantQuery.name = messagecontent[0]
session.add(myRestaurantQuery)
session.commit()
self.send_response(301)
self.send_header('Content-type','text/html')
self.send_header('Location','/restaurants')
self.end_headers()
如果它们不同,我应该寻找哪个类别来比较两者?提前致谢!