我的意思是我从使用async for
. 这是我用 编写的代码async for
,AIter(10)
可以替换为get_range()
.
但是代码运行起来像同步而不是异步。
import asyncio
async def get_range():
for i in range(10):
print(f"start {i}")
await asyncio.sleep(1)
print(f"end {i}")
yield i
class AIter:
def __init__(self, N):
self.i = 0
self.N = N
def __aiter__(self):
return self
async def __anext__(self):
i = self.i
print(f"start {i}")
await asyncio.sleep(1)
print(f"end {i}")
if i >= self.N:
raise StopAsyncIteration
self.i += 1
return i
async def main():
async for p in AIter(10):
print(f"finally {p}")
if …
Run Code Online (Sandbox Code Playgroud) 我想multiprocessing
在我的代码中使用以获得更好的性能.
但是,我收到如下错误:
Traceback (most recent call last):
File "D:\EpubBuilder\TinyEpub.py", line 49, in <module>
e.epub2txt()
File "D:\EpubBuilder\TinyEpub.py", line 43, in epub2txt
tempread = self.get_text()
File "D:\EpubBuilder\TinyEpub.py", line 29, in get_text
txtlist = pool.map(self.char2text,charlist)
File "C:\Python34\lib\multiprocessing\pool.py", line 260, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Python34\lib\multiprocessing\pool.py", line 599, in get
raise self._value
File "C:\Python34\lib\multiprocessing\pool.py", line 383, in _handle_tasks
put(task)
File "C:\Python34\lib\multiprocessing\connection.py", line 206, in send
self._send_bytes(ForkingPickler.dumps(obj))
File "C:\Python34\lib\multiprocessing\reduction.py", line 50, in dumps
cls(buf, protocol).dump(obj)
TypeError: cannot serialize '_io.BufferedReader' object …
Run Code Online (Sandbox Code Playgroud) 例如,我正在测试一个搜索页面,它将显示结果编号.text > span:nth-child(1)
。
但是,如果没有任何结果,则仅显示text="nothing"
或.text > span:nth-child(1)
不存在。
那么我怎样才能同时满足这两个条件呢?
在某些函数中matplotlib
,我们必须传递color
参数而不是cmap
参数bar3d
.
所以我们必须Colormap
手动生成.如果我有这样的dz
数组:
dz = [1,2,3,4,5]
Run Code Online (Sandbox Code Playgroud)
我想要的是:
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color=cm.jet(dz), zsort='average')
Run Code Online (Sandbox Code Playgroud)
但是,似乎它不起作用 Colormap
实例只能转换规范化数组.
>>> dz = [1,2,3,4,5]
>>> cm.jet(dz)
array([[ 0. , 0. , 0.51782531, 1. ],
[ 0. , 0. , 0.53565062, 1. ],
[ 0. , 0. , 0.55347594, 1. ],
[ 0. , 0. , 0.57130125, 1. ],
[ 0. , 0. , 0.58912656, 1. ]])
Run Code Online (Sandbox Code Playgroud)
当然,这不是我想要的.
我必须做这样的事情:
>>> cm.jet(plt.Normalize(min(dz),max(dz))(dz))
array([[ …
Run Code Online (Sandbox Code Playgroud) 我用谷歌搜索了这个问题,一些答案声明 WSL 2 现在支持 ELF 32 程序。
然而,在wsl2 Debian/Ubuntu发行版上的简单测试没有通过。
这是我的测试:
// install run-time
sudo dpkg --add-architecture i386
sudo apt-get update
// install build tools
sudo apt install build-essential
sudo apt install gcc-multilib
// build
gcc helloworld.c -m32
// run!
./a.out
bash: ./a.out: cannot execute binary file: Exec format error
Run Code Online (Sandbox Code Playgroud)
指:
我平台是Windows7
, Python3.4
,PyQt5
。
我发现我无法QImage
以 format保存对象jpeg
。
>>> from PyQt5 import QtCore, QtGui
>>> i = QtGui.QImage()
>>> i.load(r"C:\Users\paleneutron\Pictures\Capture4.PNG")
True
>>> i.save(r"C:\Users\paleneutron\Pictures\hehe.jpg")
False
>>> i.save(r"C:\Users\paleneutron\Pictures\hehe.jpg",format = 'jpeg')
False
>>> i.save('hehe.png')
True
>>> i.save('hehe.bmp')
True
>>> i.save('hehe.jpg')
False
>>> i.save('hehe.jpeg')
False
Run Code Online (Sandbox Code Playgroud)
在此页面中,jpeg
支持读和写。
为什么我这样做时出错了?
我检查了支持的格式作为评论:
>>> QtGui.QImageWriter.supportedImageFormats()
[PyQt5.QtCore.QByteArray(b'bmp'), PyQt5.QtCore.QByteArray(b'pbm'), PyQt5.QtCore.QByteArray(b'pgm'), PyQt5.QtCore.QByteArray(b'png'), PyQt5.QtCore.QByteArray(b'ppm'), PyQt5.QtCore.QByteArray(b'xbm'), PyQt5.QtCore.QByteArray(b'xpm')]
Run Code Online (Sandbox Code Playgroud)
问题就在这里,jpeg
不见了!
但是我有qjpeg.dll
。我C:\Python34\Lib\site-packages\PyQt5\plugins\imageformats
应该怎么做才能jpeg
在我的程序中启用?
换句话说,我的问题是<v-toolbar light>
'slight
实际上是什么意思?
我改变后
Vue.use(Vuetify, {
theme: {
primary: colors.purple,
secondary: colors.grey.darken1,
accent: colors.shades.black,
error: colors.red.accent3
}
})
Run Code Online (Sandbox Code Playgroud)
没有任何反应<v-toolbar>
,我必须将color
属性应用于每个元素,例如<v-btn color="primary">primary</v-btn>
.
指定颜色后,关键字dark
只会影响字体颜色。例如<v-toolbar color="primary" dark>
将显示原色和白色字体。
这不是我想要的,如何替换默认dark
和light
完全自定义的主题颜色。示例主题
我通过这个例子创建了一个入口:
$ echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: rewrite
spec:
ingressClassName: nginx
rules:
- host: my.hostname.com
http:
paths:
- path: /something(/|$)(.*)
pathType: Prefix
backend:
service:
name: http-svc
port:
number: 80
' | kubectl create -f -
Run Code Online (Sandbox Code Playgroud)
但是如果我去的my.hostname.com/something
路线不匹配,即使我改成
$ echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
name: rewrite
spec:
ingressClassName: nginx
rules:
- host: my.hostname.com
http:
paths:
- path: /something
pathType: Prefix
backend:
service:
name: http-svc
port:
number: 80
' | …
Run Code Online (Sandbox Code Playgroud) python ×4
32-bit ×1
asynchronous ×1
kubernetes ×1
linux ×1
matplotlib ×1
openshift ×1
playwright ×1
pyqt ×1
python-3.x ×1
qt ×1
vuejs2 ×1
vuetify.js ×1
windows-subsystem-for-linux ×1
x86 ×1