我一直在尝试在 Dot 中实现维恩图。虽然维恩图在 Dot 中可能没那么有用,但它主要是为了我可以将它用作非常基本的构建块。
我提供了一些我尝试过的方法:
graph G {
subgraph cluster0 {
color=white;
subgraph cluster0 {
label="1";
color=black;
a;
b;
}
subgraph cluster1 {
label="2";
color=black;
b;
c;
}
}
subgraph cluster1 {
color=white;
subgraph cluster2 {
label="1";
color=black;
d;
}
subgraph cluster3 {
label="1+2";
color=black;
e;
}
subgraph cluster4 {
label="2";
color=black;
f;
}
}
subgraph cluster2 {
color=white;
subgraph cluster5 {
label="1";
color=black;
g;
subgraph cluster6 {
label="2";
color=black;
h;
}
}
subgraph cluster6 {
label="2";
color=black;
i; …Run Code Online (Sandbox Code Playgroud) 我正在使用msvcrt.getwch以Windows为目标的Python进行交互式提示。
该文件说:
读取按键并以字节字符串形式返回结果字符。什么也没有回应到控制台。如果尚未提供按键,则该呼叫将被阻止,但不会等待按下Enter键。如果按下的键是特殊功能键,则将返回“ \ 000”或“ \ xe0”;下一次调用将返回键码。使用此功能无法读取Control-C按键。
我发现F10使用前者- \x00D,F11使用后者\xe0\x85。
但是,这并未说明键码是什么。这很重要,因为\xe0除了其他键之外,我没有键(à),因此无法测试输入此值的输出。
其他方面
例如,我尝试过两种方式将此键粘贴到提示中。
\x16。这是ASCII中的同步空闲密钥。[1](这是我输入的组合键。)右键单击(在PS中粘贴)-结果仅\xe0被输入。
我不确定Power Shell和Visual C ++是否允许我粘贴转义序列,或者这是对该键的实际处理。
鉴于这msvcrt似乎是Visual C ++的包装,我也查看了该文档。
_getch和_getwch函数从控制台读取单个字符,而不回显该字符。这些功能均不能用于读取CTRL + C。读取功能键或箭头键时,每个功能必须调用两次;第一次调用返回0或0xE0,第二次调用返回实际的密钥代码。
这也没有说出键码是什么。
我在网上看过,但是我只能找到有关虚拟键码的信息,但是这表示F10是\x79,F11是\x7A。由于此函数未返回这些值,因此我知道它没有引用这些键码。
所以这是一个非常简单的问题.如何添加__getitem__到Python模块.我大多只是希望它易于使用,但令人困惑的是它为什么不让我"设置它".下面是一个简单的__getitem__半工作示例,但我希望other['test']能够工作.
这是完整的输出:
hello
hello
Traceback (most recent call last):
File "main.py", line 4, in <module>
print other['test']
TypeError: 'module' object has no attribute '__getitem__'
Run Code Online (Sandbox Code Playgroud)
main.py
import other
print other.get('test')
print other.__getitem__('test')
print other['test']
Run Code Online (Sandbox Code Playgroud)
other.py
test = 'hello'
def __getitem__(name):
return globals()[name]
get = __getitem__
Run Code Online (Sandbox Code Playgroud)
我试图设置__getitem__使用globals()藏汉,globals()['__getitem__'] = __getitem__.它没用.我试着把它设置好main.py.所以我很困惑为什么它坚持不允许我使用它other['test'].
如果这是不可能的,那么一个简短的理由就是好的.