我有一堂課
class Employee(BaseModel):
Emp_ID: int
Emp_Name: str
Emp_Qualification: str
下面是 POST 請求的代碼,我在上次嘗試獲取員工 ["Emp_id"] 值時遇到錯誤。
@app.api_route("/post-details/{postid}", methods=["POST"])
def post(postid: int , employee : Employee):
newlist = []
cursor=conn.cursor()
getemploy2= "select id from employee3"
cursor.execute(getemploy2)
result = cursor.fetchall()
for list in result:
newlist.extend(list)
if postid in newlist:
return "yes it exist"
return employee(["Emp_ID"])
uj5u.com熱心網友回復:
您可以使用.運算子訪問物件的屬性:
return employee.Emp_ID
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/390106.html
