小编Q.H*_*.H.的帖子

URLResourceKey.quarantinePropertiesKey仅在安装chromedriver时在OS X 10.10或更高版本上可用

我下载chromedriver通过brew cask install(见相关的问题),当我尝试下载它,我得到以下错误(粘贴从命令条目全输出):

(env) MacBook:project_dir owner$ brew cask install chromedriver
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
dnstwist            grpc                pdns                uftp
firebase-cli        lf                  pdnsrec             wildfly-as
glslviewer          libxlsxwriter       tile38              zabbix

==> Satisfying dependencies
==> Downloading https://chromedriver.storage.googleapis.com/2.41/chromedriver_ma
######################################################################## 100.0%
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/utils/quarantine.swift:29:30: error: 'quarantinePropertiesKey' is only available on OS X 10.10 or newer
      forKey: URLResourceKey.quarantinePropertiesKey
                             ^
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/utils/quarantine.swift:29:30: note: add 'if #available' version check
      forKey: URLResourceKey.quarantinePropertiesKey
                             ^
Error: Failed to quarantine /Users/user/Library/Caches/Homebrew/downloads/42621d77ecaa889fa8ca73ac4b2a2228e3c1d11f20d84c6898e7645397d00f1d--chromedriver_mac64.zip. Here's the …
Run Code Online (Sandbox Code Playgroud)

homebrew selenium-chromedriver homebrew-cask

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

如何在 Anaconda Env 中启动 Visual Studio Code

我在 Windows 10 PC 上的 Visual Studio 代码中运行 python 程序时遇到问题。

当我从终端启动 python 会话并说import cv2我没有收到错误时:

在此处输入图片说明

当我通过命令提示符并VSCode从环境中开始时,我得到ModuleNotFoundError

在此处输入图片说明

Traceback (most recent call last): File "gui.py", line 3, in <module> import cv2 ModuleNotFoundError: No module named 'cv2'

当我尝试python gui.py从环境中运行程序时,我的命令提示符崩溃并显示错误消息:

在此处输入图片说明

除了想知道有没有办法从 python env 中启动我的 IDE 以便它可以找到所有本地包之外,我不知道如何问这个问题。

python python-3.x anaconda

7
推荐指数
1
解决办法
2万
查看次数

Swift 中的音频播放未恢复到原始音量

我正在尝试播放“叮”声以提醒用户发生事件。播放“叮”但背景音频(在本例中为默认 Music.App)在播放“叮”后没有恢复到其原始音量。但是,关闭应用程序后它将恢复正常音量。这就是我所拥有的:

这是我设置音频会话类别的地方:

     public override func viewDidLoad() {
            super.viewDidLoad()
            do {
                try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, withOptions: AVAudioSessionCategoryOptions.DuckOthers)
                //refer to this link for swift's sound reference: https://developer.apple.com/ios/human-interface-guidelines/interaction/audio/
            } catch {
                print("unable to load audio session")
            }
            ....
     }
Run Code Online (Sandbox Code Playgroud)

这是我调用我的函数的地方:

if(!currentTimer.launchedNotification){
            playFinishedSound()
            AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate)) //handles phone vibration
            audioPlayerDidFinishPlaying(audioPlayer!, successfully: true)

        }
Run Code Online (Sandbox Code Playgroud)

这是我的私人功能:

private func playFinishedSound(){
        if let pathResource = NSBundle.mainBundle().pathForResource("Ding", ofType: "wav"){
            let soundToPlay = NSURL(fileURLWithPath: pathResource)
            do {
                audioPlayer = try AVAudioPlayer(contentsOfURL: soundToPlay)
                if(audioPlayer!.prepareToPlay()){
                    print("preparation success")
                    audioPlayer!.delegate = self
                    setAVAudioSession()
                    if(audioPlayer!.play()){
                        print("Sound play success") …
Run Code Online (Sandbox Code Playgroud)

avaudioplayer ios avaudiosession swift

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

Python 2.7-使用Xvfb进行Selenium无头测试无法正常工作

注意我已经看过以下来源:

easyprocess.EasyProcessCheckInstalledError:cmd = ['Xvfb','-help'] OSError = [Errno 2]没有这样的文件或目录

如何在Xvfb中运行Selenium?

哪个没有解决我的问题。

我在用:

  • Python 2.7
  • 硒3.0.2
  • xvfbwrapper 0.2.9
  • PyVirtualDisplay 0.2.1

在Mac OSX El Capitan(10.11.6(15G1108))上运行

我收到以下错误(与上述链接中的错误相同):

Traceback (most recent call last):
  File "/Users/user/Desktop/test.py", line 50, in <module>
    display = Display(visible=0, size=(800, 600))
  File "/Library/Python/2.7/site-packages/pyvirtualdisplay/display.py", line 34, in __init__
    self._obj = self.display_class(
  File "/Library/Python/2.7/site-packages/pyvirtualdisplay/display.py", line 52, in display_class
    cls.check_installed()
  File "/Library/Python/2.7/site-packages/pyvirtualdisplay/xvfb.py", line 38, in check_installed
    ubuntu_package=PACKAGE).check_installed()
  File "/Library/Python/2.7/site-packages/easyprocess/__init__.py", line 180, in check_installed
    raise EasyProcessCheckInstalledError(self)
EasyProcessCheckInstalledError: cmd=['Xvfb', '-help']
OSError=[Errno 2] No such file or directory …
Run Code Online (Sandbox Code Playgroud)

macos python-2.7 selenium-webdriver

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

Python中集差函数的运行时间是多少?

这个问题解释了它,但是Python中的集差运算的时间复杂度是多少?

前任:

A = set([...])
B = set([...])

print(A.difference(B)) # What is the time complexity of the difference function? 
Run Code Online (Sandbox Code Playgroud)

我的直觉告诉我,O(n)因为我们可以遍历集合 A 并且对于每个元素,查看它是否在恒定时间内(使用哈希函数)包含在集合 B 中。

我对吗?

(这是我遇到的答案:https : //wiki.python.org/moin/TimeComplexity

python set

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

AVAudioPlayer没有播放音频Swift

我试图播放声音作为我的应用程序用户的警报,我已经看了几个来源,试图帮助我这样做:

AVAudioPlayer没有在Swift中播放音频(帮我解决我现在遇到的问题,无济于事)

快速创建和播放声音(我最初开始的地方)

这些视频:

https://www.youtube.com/watch?v=Kq7eVJ6RSp8

https://www.youtube.com/watch?v=RKfe7xzHEZk

所有这些都没有给我预期的结果(声音没有播放).

这是我的代码:

private func playFinishedSound(){
        if let pathResource = NSBundle.mainBundle().pathForResource("3000", ofType: "mp3"){
            let finishedStepSound = NSURL(fileURLWithPath: pathResource)
            var audioPlayer = AVAudioPlayer()
            do {
                audioPlayer = try AVAudioPlayer(contentsOfURL: finishedStepSound)
                if(audioPlayer.prepareToPlay()){
                    print("preparation success")
                    audioPlayer.delegate = self
                    if(audioPlayer.play()){
                        print("Sound play success")
                    }else{
                        print("Sound file could not be played")
                    }
                }else{
                    print("preparation failure")
                }

            }catch{
                print("Sound file could not be found")
            }
        }else{
            print("path not found")
        }
    }
Run Code Online (Sandbox Code Playgroud)

目前我看到"准备成功"和"声音播放成功",但没有播放声音.我实现它的类是一个AVAudioPlayerDelegate,该文件名为"3000.mp3",它位于项目目录中.在上下文中,此方法称为:

private func finishCell(cell: TimerTableViewCell, currentTimer: TimerObject){
        currentTimer.isRunning …
Run Code Online (Sandbox Code Playgroud)

avaudioplayer ios swift

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

Erlang"badarg",不确定如何处理

在我开始之前,我已经检查过Erlang中的Handle badarg 但是我在未定义的检查中仍然没有成功,所以我删除了它们.

我正在建立一个虚拟银行流程,当客户端对银行流程进行余额查询检查时,程序退出,说:

Error in process <0.373.0> with exit value:
{badarg,[{project4,client,3,
                   [{file,"/Users/owner/Desktop/bank.erl"},
                    {line,27}]}]}

=ERROR REPORT==== 26-Oct-2016::13:34:57 ===
Error in process <0.379.0> with exit value:
{badarg,[{project4,client,3,
                   [{file,"/Users/owner/Desktop/bank.erl"},
                    {line,27}]}]}

=ERROR REPORT==== 26-Oct-2016::13:34:57 ===
Error in process <0.375.0> with exit value:
{badarg,[{project4,client,3,
                   [{file,"/Users/owner/Desktop/bank.erl"},
                    {line,27}]}]}

=ERROR REPORT==== 26-Oct-2016::13:34:58 ===
Error in process <0.377.0> with exit value:
{badarg,[{project4,client,3,
                   [{file,"/Users/owner/Desktop/bank.erl"},
                    {line,27}]}]}
<0.378.0> Balance request: 54> 
=ERROR REPORT==== 26-Oct-2016::13:34:58 ===
Error in process <0.378.0> with exit value:
{badarg,[{project4,client,3,
                   [{file,"/Users/owner/Desktop/bank.erl"},
                    {line,39}]}]}
<0.372.0> Balance request: 54> 
=ERROR …
Run Code Online (Sandbox Code Playgroud)

erlang

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

使用jQuery $(this)对象删除元素不起作用

我试图删除我的html页面上的一个对象,该对象是用jQuery动态添加的,当然,它不是删除元素.下面是一小段jQuery代码,下面是我的HTML代码.当我查看控制台日志时,消息已成功打印,但对象仍在屏幕上.是否有我遗漏的内容?

发生了什么:
当用户点击<h1>元素"MATH"时,应该在其下面出现一个带有"content"类的div.然后,当单击该div元素时,应删除该对象.

jQuery代码:

 $(document).ready(function (){
        var subject = $('.subject');
        var content = "<ul style='list-style-type: none;'> <li>some text</li> </ul>";
        subject.click(function(){
            $(this).append('<div class="content">' + content + '</div>');
        });
        $(document).on('click','div.content', function(){
            console.log("no such luck");//this prints
            $(this).remove();//this does not remove element however
        });
    });
Run Code Online (Sandbox Code Playgroud)

HTML代码:

<!DOCTYPE html>
<html>
...

<body>
    <div class="jumbotron" style="background-color: lightblue; height: 25%;">
        <h1 class="subject" target="1">MATH</h1>
    </div>
 </body>
 </html>
Run Code Online (Sandbox Code Playgroud)

我之前在Codeacademy示例中使用过上面的代码,它运行正常.

html jquery

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

graphviz在决策树的每个节点内呈现的值是什么意思?

在此处输入图片说明

对于上面的图像,使用的AdaBoostClassifier库scipygraphviz我能够创建此子树视觉效果,我需要帮助来解释每个节点中的值吗?例如,“ gini”是什么意思?“样本”和“值”字段的意义是什么?属性F5 <= 0.5是什么意思?

这是我的代码(我在jupyter笔记本中全部完成了此操作):

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
%matplotlib inline

f = open('dtree-data.txt')
d = dict()
for i in range(1,9):
    key = 'F' + str(i)
    d[key] = []
d['RES'] = []
for line in f:
    values = [(True if x == 'True' else False) for x in line.split()[:8]]
    result = line.split()[8]
    d['RES'].append(result)
    for i in range(1, 9):
        key = 'F' + str(i)
        d[key].append(values[i-1]) …
Run Code Online (Sandbox Code Playgroud)

python scipy pygraphviz scikit-learn

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

如何获取故事板的字符串名称?

我已经查看了以下指导无济于事:

如何知道当前的故事板名称?

我正在尝试使用我的故事板从基于以下答案的远程通知中打开特定的视图控制器:

使用 Swift 在 didReceiveRemoteNotification 中显示特定的视图控制器

    let mvc = MainViewController()
    let storyBoardNameString = mvc.storyboard. //<-proposed solution? Nothing from auto complete shows up
    let storyboard = UIStoryboard(name: storyBoardNameString , bundle: nil) 
    storyboard.instantiateViewControllerWithIdentifier("some-view-controller")
Run Code Online (Sandbox Code Playgroud)

我已经检查了“文件检查器”、“快速帮助检查器”、“身份检查器”、“属性检查器”、“大小检查器”,甚至“连接检查器”,但也没有运气。

当我在我的故事板上选择一个视图控制器并试图找到当前故事板的名称时,我只能找到视图的故事板 ID,而不是故事板的名称。

任何解决方案将不胜感激,否则我将尝试找到另一种方法来完成我的任务。

storyboard ios swift

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

TLA +:如何删除结构键/值对?

我有一个规范试图在其中定义LRU Cache系统,而我遇到的问题之一就是如何从结构键/值对(基本上是字典或哈希表)中删除值其他语言)。

这是到目前为止的规范本身(不完整):

EXTENDS Integers, Sequences
VARIABLES capacity, currentSize, queue, dictionary

Init == /\ (capacity = 3 ) /\ (currentSize = 0)
        /\ (queue = <<>>) /\ (dictionary = [])


AddItem(Item, Value) == IF currentSize < capacity
            THEN /\ currentSize' = currentSize + 1
                 /\ queue' = Append(queue, Item)
                 /\ dictionary[item] = value
            ELSE /\ queue' = Append(Tail(queue), Item) 
                 /\ dictionary' = [x \in dictionary: x /= queue[3]]

GetItem(Item) == dictionary[item]

Next == \/ AddItem 
        \/ GetItem
Run Code Online (Sandbox Code Playgroud)

在Learn TLA …

lru tla+

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