我正在学习python,我把ctype和ctypes搞混了。在讲座中,讲师使用了ctype,我搜索了它,但只搜索了ctypes模块的结果。
所以我不确定ctype和ctypes在python中是否相同。在官方文档中,我必须导入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()
如果它们是不同的,我应该找哪一个类别来比较两者?提前谢谢!在
在什么背景下?仅仅因为某个名字出现在代码中并不意味着你会从网络搜索中得到有意义的结果。你需要知道为什么选择这个名字,以及那个程序员的意图是什么。在
ctypes模块是与C(语言)类型交互的一种方式,而您在问题中所指的ctype代表内容类型。请看这里https://docs.python.org/2/library/cgi.html
相关问题 更多 >
编程相关推荐