所以我已经在Windows 10计算机上安装了Python 3.6一段时间了,今天我才通过admin命令行通过以下命令下载并安装了graphviz 0.8.2(https://pypi.python.org/pypi/graphviz)软件包:
pip3 install graphviz
仅在此之后,我下载了Graphviz 2.38 MSI安装程序文件并在以下位置安装了该程序:
C:\Program Files (x86)\Graphviz2.38
因此,我尝试运行此简单的Python程序:
from graphviz import Digraph
dot = Digraph(comment="The round table")
dot.node('A', 'King Arthur')
dot.node('B', 'Sir Bedevere the Wise')
dot.node('L', 'Sir Lancelot the Brave')
dot.render('round-table.gv', view=True)
Run Code Online (Sandbox Code Playgroud)
但是不幸的是,当我尝试从命令行运行Python程序时,收到以下错误消息:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\graphviz\backend.py", line 124, in render
subprocess.check_call(args, startupinfo=STARTUPINFO, stderr=stderr)
File "C:\Program Files\Python36\lib\subprocess.py", line 286, in check_call
retcode = call(*popenargs, **kwargs)
File "C:\Program Files\Python36\lib\subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as …Run Code Online (Sandbox Code Playgroud) 在C ++中,我经常需要使用一个非常简单的原始对象,该对象仅包含各种数据类型,以便可以在函数之间轻松传递它。在Python中,我通过使用字典来实现这一点。例如:
easy = {"keyframe_range":[], "value":0.25, "interpolation":"bezier"}
Run Code Online (Sandbox Code Playgroud)
但是,在C ++中,如果我想创建类似的东西,则需要:
struct obj
{
vector<int> keyframe_range;
float value;
string interpolation;
obj(vector<int> vv, float ff, string ss) : keyframe_range(vv), value(ff), interpolation(ss) {}
};
obj easy(vector<int>(), 0.25, "bezier");
Run Code Online (Sandbox Code Playgroud)
当我需要一时兴起地创建知道对象的对象时,为我需要的每个对象手动编写一个参数化的构造函数是非常低效率的,而且浪费大量时间。在Python中,我基本上可以使用字典来避免这种情况;但是,C ++中的unordered_maps必须映射到相同的数据类型,因此它们并不是我真正想要的。
本质上,我只是想要一种简单的方法来创建一个简单的对象,该对象充当各种数据类型的项目的集合,仅此而已。可以在C ++ 11中完成吗?
c++ ×1
c++11 ×1
constructor ×1
graphviz ×1
installation ×1
object ×1
pip ×1
python ×1
python-3.x ×1