在回答这个问题时,我发现了一些我没有解释的奇怪行为
for /f "delims=" %a in ('(for /l %z in (1,1,10^) do @echo %z^)') do @echo %a0
Run Code Online (Sandbox Code Playgroud)
您将看到数字10..100,现在只需添加管道,例如,sort
或者more
,或者:
for /f "delims=" %a in ('(for /l %z in (1,1,10^) do @echo %z^)^|sort') do @echo %a0
Run Code Online (Sandbox Code Playgroud)
%a
和之间会有空格0
!看起来像通过管道回声的东西增加了一个尾随空格,可以很容易地看到:
>_tempfile echo no space here
>_tempfile echo and here's a space|more
Run Code Online (Sandbox Code Playgroud)
乃至
>_tempfile <nul set /p =also a space|sort
Run Code Online (Sandbox Code Playgroud)
(可能使用echo来打印提示)
当没有输出重定向(无论是文件还是命令)时,都不会发生这种情况.这是一个错误还是我错过了什么?我如何摆脱空间?(除了剥去最后一个角色的肮脏黑客var:~0,-1
)
可能重复:
使用Python 3 super()
在Python 3.2的文档中,它说;
如果省略第二个参数,则返回的超级对象是未绑定的
根据我的理解,未绑定(如'unbound-to-instance')对象是从super(class,class)返回的对象.那么,超级(类)中的'未绑定'是什么意思?你怎么绑它?
class Base:
def printme(self): print("I'm base")
class Derived(Base):
def printme(self): print("I'm derived")
class Derived2(Derived):
def printme(self):
super().printme()
# next-in-mro bound-to-self method
super(Derived, self).printme()
# beyond-Derived-in-mro bound-to-self method
super(Derived, Derived2).printme(self)
# beyond-Derived-in-mro-of-Derived2 unbound method
super(Derived2).printme
# WTF is this? There's not even a printme attribute in it
Derived2().printme()
Run Code Online (Sandbox Code Playgroud) 我有一个静态结构数组:
struct CommandStruct
{
char* data;
unsigned ans_size;
};
static const CommandStruct commands[] =
{
{ "Some literal", 28 },
{ "Some other literal", 29 },
{ "Yet another literal", 8 },
};
Run Code Online (Sandbox Code Playgroud)
我希望字符串是 16 字节对齐的。可以直接实现吗?我可能会单独定义每个文字,例如__declspec(align(16)) static const char some_command_id[] = "my literal"
,但这很混乱。我需要在一个代码块中进行所有初始化。