python 中的 c 类型和类型有区别吗?

Are ctype and ctypes different in python?

我正在学习 python 并且对 ctype 和 ctypes 感到困惑。在讲座中,讲师使用 ctype,我搜索了它,但只有 ctypes 模块结果。 所以我不确定 python 中的 ctype 和 ctypes 是否相同。在官方文档中,我必须导入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

In the lecture, the instructor uses ctype and I searched it

在什么情况下?仅仅因为某个名称出现在代码中的某处并不意味着您将从网络搜索中获得有意义的结果。你需要知道为什么选择这个名字,以及那个程序员的意图是什么。