你如何在 Polka.js 框架中设置响应状态码

问题描述

看起来应该很简单。

尝试:

Find

抓住我:

TypeError: res.status 不是函数

这是在工兵中,不确定这是否有所不同。

解决方法

根据 the docs,您使用 self,或者如果您在中间件中抛出错误,您将使用 import random,copy class cards: chest_cards = (["Go to..."]) chance_cards = (["Go to Ja..."]) def __init__(self): #before you over-write self.chest_cards,it refers to the class attribute self.chest_cards = copy.copy(self.chest_cards) #make a local copy so you don't alter the master list #after you over-write it,it will refer to the instance attribute as long as you made a copy. #you can also refer to the class directly to access class-attributes self.chest_cards = copy.copy(cards.chest_cards) #if you want to get the class without calling it by name (in case you want to change the name of the class) self.chest_cards = copy.copy(type(self).chest_cards) random.shuffle(self.chest_cards)

,

具体做法如下:

res.writeHead(500,{'Content-Type': 'text/plain'})

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...