我正在研究macOS Sierra中的自动化东西(10.12.2).通过使用python的atomac支持,我可以启动Safari浏览器并通过Safari启用设置 - >首选项 - >高级 - >选中"启用开发菜单",然后选择"开发 - >允许远程自动化".看起来这对于自动化角度来说并不是那么一致.我想知道是否有任何shell命令可以实现这一点.
假设我有两个列表,如下所示:
list1 = ["a","b","a","a","b","a","b","a","b","b","b"]
list2 = ["pos","neg","pos","neu","neg","pos","pos","pos","neg","neu","pos"]
Run Code Online (Sandbox Code Playgroud)
我要计算的次数"pos","neg"并且"neu"发生在中的每个项目上list1。
所以,次数"pos","neg"和"neu"使用时"a",和"b"。例如,在所述第一元件list1,"a"具有一"pos"值,因为list2[0]为"pos"。
最好的方法是什么?与目前相比,我觉得有更好的解决方案。我可以看到,如果list1我的方法中存在更多独特的项目,将是不可行的。
list1 = ["a","b","a","a","b","a","b","a","b","b","b"]
list2 = ["pos","neg","pos","neu","neg","pos","pos","pos","neg","neu","pos"]
Run Code Online (Sandbox Code Playgroud) 我是Python类的新手,并试图理解继承的概念.我有一个叫做Math继承自的类Calc.从Math.product()我试图调用基类方法mul()如下:
class Calc(object):
def mul(a, b):
return a * b
class Math(Calc):
def product(self, a, b):
return super(Math, self).mul(a, b)
if __name__ == "__main__":
m = Math()
print "Product:", m.product(1.3, 4.6)
Run Code Online (Sandbox Code Playgroud)
当我跑我得到下面的错误,但据我可以告诉我只通过了两项args作为代码mul()内Math.product(a,b).有人能说清楚我犯了什么错误吗?
Product:
Traceback (most recent call last):
File "inheritance.py", line 14, in <module>
print "Product:", m.product(1.3, 4.6)
File "inheritance.py", line 9, in product
return super(Math, self).mul(a, b)
TypeError: mul() takes exactly 2 arguments (3 given)
Run Code Online (Sandbox Code Playgroud)