什么是2d矢量类/操作的numpy等价物euclid?(如:euclid.Vector2)
到目前为止,我有这个.创建两个向量
import numpy as np
loc = np.array([100., 100.])
vel = np.array([30., 10])
loc += vel
# reseting speed to a default value, maintaining direction
vel.normalize()
vel *= 200
loc += vel
Run Code Online (Sandbox Code Playgroud) 我无法导入fluidynth.[也许有更好的模块?]
我正在尝试从python或pygame合成midi.我可以从pygame发送midi事件.我正在使用mingus,似乎pyfluidsynth会很好/最简单.
我认为这意味着安装了pyfluidsynth,但是没有单独的fluidlyth.我不知道它是否需要'fluidynth'安装程序才能工作?
test.py:
import fluidsynth
print ":("
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import fluidsynth
File "C:\Users\jake\AppData\Roaming\Python\Python27\site-packages\fluidsynth.py", line 34, in <module>
raise ImportError, "Couldn't find the FluidSynth library."
ImportError: Couldn't find the FluidSynth library.
Run Code Online (Sandbox Code Playgroud)
使用:python 2.7-win32
我有一个类 Text(),它缓存它的表面以进行渲染,除非字体/大小发生变化。(我从代码片段中留下了字体属性)
self.sizein __init__,它将失败:Traceback (most recent call last):
File "temp.py", line 21, in <module>
t = Text("arial", 6)
File "temp.py", line 3, in __init__
self.size = size
File "temp.py", line 16, in size
if self._size != px:
AttributeError: 'Text' object has no attribute '_size'
Run Code Online (Sandbox Code Playgroud)
我能够分配self._textin __init__,但我认为这是错误的,因为:
_text更改,代码可能会中断,但如果它使用该属性,则可能没问题。class Text(object):
def __init__(self, font, size=12):
self.size = size
self.font = font
self.dirty = False
def draw(self):
print "Draw: ", …Run Code Online (Sandbox Code Playgroud) 我可以读取标签,除非有前缀。我没有运气寻找上一个问题。
我需要阅读media:content。我试过了image = node.find("media:content")。Rss输入:
<channel>
<title>Popular Photography in the last 1 week</title>
<item>
<title>foo</title>
<media:category label="Miscellaneous">photography/misc</media:category>
<media:content url="http://foo.com/1.jpg" height="375" width="500" medium="image"/>
</item>
<item> ... </item>
</channel>
Run Code Online (Sandbox Code Playgroud)
我可以阅读同级标签title。
from xml.etree import ElementTree
with open('cache1.rss', 'rt') as f:
tree = ElementTree.parse(f)
for node in tree.findall('.//channel/item'):
title = node.find("title").text
Run Code Online (Sandbox Code Playgroud)
我一直在使用文档,但仍停留在“前缀”部分。
我想为其创建一个别名Get-Help [foo] -online.但我无法得到有关工作的论据.
我试了几件事,包括 Set-Alias -Name mano -Value "Get-Help -online"
PS C:\Program Files\ConEmu> mano Get-Content
Cannot resolve alias 'mano' because it refers to term 'Get-Help -online',
which is not recognized as a cmdlet, function, operable program, or script
file. Verify the term and try again.
At line:1 char:5
+ mano <<<< Get-Content
+ CategoryInfo : ObjectNotFound: (mano:String) [], CommandNo
tFoundException
+ FullyQualifiedErrorId : AliasNotResolvedException
Run Code Online (Sandbox Code Playgroud) 我.svg使用Inkscape 生成一个图像(这是一个xml文件).我将节点的ID设置为'mount-arm-r'.我想从该元素中读取属性'x','y'.我似乎无法选择rect元素.
python:我尝试过XPath,或者一次手动一个深度.我想我想:
def parse_xml():
tree = ElementTree()
tree.parse("torso-human.svg")
for node in tree.findall('.//rect'): print 'n=', node
Run Code Online (Sandbox Code Playgroud)
XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="125.39109"
height="217.70497"
id="svg3136"
version="1.1"
inkscape:version="0.48.1 "
sodipodi:docname="torso-human.svg">
<defs
id="defs3138" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="134.17406"
inkscape:cy="65.046531"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="678"
inkscape:window-height="714"
inkscape:window-x="149"
inkscape:window-y="198"
inkscape:window-maximized="0" />
<metadata
id="metadata3141">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" …Run Code Online (Sandbox Code Playgroud) python ×5
xml ×2
elementtree ×1
markdown ×1
midi ×1
numpy ×1
powershell ×1
properties ×1
scite ×1
synthesizer ×1
xml.etree ×1