小编py_*_*bie的帖子

在蟒蛇中揭开神秘的神秘面纱?

我试图了解python中的超级工作方式,并尝试了以下示例:

class A(object):
    def __init__(self):
        print "in A's init"

class B(object):
    def __init__(self):
        print "in B's init"

class C(A,B):
    def __init__(self):
        super(C,self).__init__()
        print "In C"

if __name__=="__main__":
    c=C()
Run Code Online (Sandbox Code Playgroud)

相当简单..我尝试了以下超级调用(在此处显示结果):

>>> super(B,c).__init__()
>>> super(B,c).__init__()
>>> super(A,c).__init__()
    in B's init
>>> super(A,c).__init__()
    in B's init
>>> super(A,c).__init__()
    in B's init
>>> super(B,c).__init__()
>>> super(C,c).__init__()
    in A's init
Run Code Online (Sandbox Code Playgroud)

我不明白为什么super(A,c).__init__()在B的init 中打印出它?

python super

4
推荐指数
1
解决办法
197
查看次数

在引号powershell中的字符串中转义@

我正在尝试使用powershell运行curl命令,如下所示:

$command=".\curl.exe -k -X POST --data @login.txt -H ""Content-Type:application/json;charset=utf-8"" https://myserversfqdn:4443/ControlPoint/api/v1/login"

$res= Invoke-Expression $command

它给出了一个错误,说splatting operator @不能用于引用表达式中的变量..所以我在@ login.txt之前添加一个反引号..

$command=".\curl.exe -k -X POST --data '@login.txt -H ""Content-Type:application/json;charset=utf-8"" https://myserversfqdn:4443/ControlPoint/api/v1/login"

$res= Invoke-Expression $command

现在它给我一个错误,说表达式缺少一个终结符'(反引号)..我迷失了如何在这个命令中传递@字符?任何指导都非常感谢

powershell curl escaping powershell-3.0

1
推荐指数
1
解决办法
2146
查看次数

标签 统计

curl ×1

escaping ×1

powershell ×1

powershell-3.0 ×1

python ×1

super ×1