使用 Vite 的开发服务器,如果我尝试访问不存在的 URL(例如localhost:3000/nonexistent/index.html),我会收到404错误。相反,我收到一个200状态代码以及localhost:3000/index.html.
在这种情况下,如何配置 Vite 使其返回 a 404?
(这个问题:Serve a 404 page with app created with Vue-CLI非常相似,但与基于 Webpack 的 Vue-CLI 而不是 Vite 相关。)
考虑以下代码(从这里开始,测试数量增加):
from timeit import Timer
def find_invpow(x,n):
"""Finds the integer component of the n'th root of x,
an integer such that y ** n <= x < (y + 1) ** n.
"""
high = 1
while high ** n < x:
high *= 2
low = high/2
while low < high:
mid = (low + high) // 2
if low < mid and mid**n < x:
low = mid
elif high > mid and mid**n > x: …Run Code Online (Sandbox Code Playgroud) 我正在写一个简单的游戏.我的图形代码每帧运行一次(大约每秒30次),并将RGB数据写入640*480 = 307200个条目的数组.
我创建了一个Win32窗口,其客户区域大小为640 x 480像素.在其他空窗口中显示我的RGB数据的最快方法是什么?
窗口需要每帧更新,所以我需要避免闪烁.我应该使用GDI吗?或者是否有更快的方法使用不同的库 - 比如DirectDraw?
编辑:
感谢所有的答复.首先,让我排除Direct2D作为选项 - 我需要支持Windows XP.其次,我有3D背景,所以Yann Ramin和Ben Voigtto建议的方法 - 使用Direct3D/OpenGL和单个纹理四边形 - 是我过去总是这样做的.
但是,我有兴趣了解2D API是否是更好的解决方案.由于没有明确的答案,我把测试程序汇总在一起.代码只是在屏幕上反复显示帧缓冲,尽可能快.
我已将结果发布为此后续问题的一部分.
正如目前在这个问题中讨论的那样,我正在编写内置函数range和xrange函数的包容性版本.如果将它们放在名为的模块中inclusive,我会看到两种可能的方法来命名函数本身:
命名函数inclusive_range,inclusive_xrange以便客户端代码可以使用它们,如下所示:
from inclusive import *
...
inclusive_range(...)
Run Code Online (Sandbox Code Playgroud)命名函数range和xrange:
import inclusive
...
inclusive.range(...)
Run Code Online (Sandbox Code Playgroud)对我来说,客户端代码的第二个示例看起来更好,但是我应该避免以这种方式重用内置名称吗?
If s是slicePython中的一个对象,使用s = slice(start, stop, step)或者(在适当的上下文中)start:stop:step构造,用于构造的值s可以从slice对象本身获得s.start,s.stop和s.step.
类似的start,stop并且step成员可在range在Python 3.4 [对象Issue9896.例如,range(1, 4, 2).start == 1.
然而,Python 2.7版xrange的对象不具备start,stop和step成员.有没有其他方法可以获取用于构造xrange对象本身的值?
在Python中,我可以向C先前定义的类添加属性。但是,我无法向其中添加属性list-产生的错误消息说明这是因为list是内置类型:
>>> class C: pass
...
>>> C.foo = 1
>>> C.foo
1
>>> list.foo = 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't set attributes of built-in/extension type 'list'
Run Code Online (Sandbox Code Playgroud)
同样,可以将属性添加到的实例C,但不能添加到的实例list。但是,在这种情况下,错误消息更加模糊:
>>> o = C()
>>> o.bar = 2
>>> o.bar
2
>>> o = []
>>> o.bar = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object …Run Code Online (Sandbox Code Playgroud) 该FOLDR与foldl与foldl”维基页面描述之间的差异foldr和foldl。两个进程都从左到右列出,但foldr从右到左累积结果,而从左到右累积结果foldl。
该页面继续不鼓励使用 ,foldl而支持foldl'更高效的 Eager 版本。
是否有相应的热切版本foldr,大概称为foldr'?如果是这样,是否有原因未在 wiki 页面上提及?
使用yield return将方法变成迭代器。迭代器的返回类型必须是IEnumerable、IEnumerable<T>、IEnumerator或IEnumerator<T>。
我发现迭代器只能foreach在返回其中一种IEnumerable类型的情况下在循环中使用。考虑到这一限制,什么时候选择IEnumerator返回类型而不是才有意义IEnumerable?
如果我python -m http.server在命令行上运行,然后在浏览器中导航到不包含 的目录index.html,我会看到一个目录列表(如此处所述)。
然而,在这种情况下,生产服务器通常会拒绝列出目录的内容,而是返回状态403或404。我可以配置http.server做同样的事情吗?
我创建了一个沙箱git存储库,其中包含一些提交和几个标签,一个是轻量级的,另一个是带注释的:
> mkdir one; cd one; git init
> touch a.txt; git add a.txt; git commit -m"a.txt"
> touch b.txt; git add b.txt; git commit -m"b.txt"
> git tag light
> touch c.txt; git add c.txt; git commit -m"c.txt"
> git tag -a annot -m"annot"
Run Code Online (Sandbox Code Playgroud)
现在,我创建第二个存储库并从第一个存储库获取:
> mkdir two; cd two; git init
> git remote add one <...>/one
> git fetch one master
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 2), …Run Code Online (Sandbox Code Playgroud) python ×5
attributes ×1
c# ×1
devserver ×1
directdraw ×1
directory ×1
dynamic ×1
fold ×1
gdi ×1
git ×1
git-fetch ×1
haskell ×1
http ×1
ienumerable ×1
ienumerator ×1
iterator ×1
object ×1
oop ×1
performance ×1
python-2.7 ×1
python-3.x ×1
range ×1
rgb ×1
server ×1
tags ×1
vite ×1
vue.js ×1
winapi ×1
xrange ×1