我在对话框表单上有一个文本框,我想在表单加载后默认关注它,但由于某种原因,它不会发生.我尝试过:Focus和form_load事件,并在表单初始化后立即放置焦点方法.
我正在尝试google customsearch api来搜索图片,但奇怪的是我通过api搜索返回的结果与通过浏览器的常规搜索不同.例如
from apiclient.discovery import build
import pprint
import sys
api_key='xxxxxxx'
service = build('customsearch', 'v1', developerKey=api_key)
request=service.cse()
query=request.list(cx='xxxx:xxxxx',q='dogs and cats',searchType='image',imgType='photo')
result=query.execute()
pprint.pprint(result)
for i in result.get('items',[]):
print (i['link'])
Run Code Online (Sandbox Code Playgroud)
运行此代码会产生完全不同的结果,这是运行上面代码的结果
https://s.yimg.com/ny/api/res/1.2/tarWzt2ZXfPOEg8oQVlOWw--/YXBwaWQ9aGlnaGxhbmRlcjtzbT0xO3c9ODAw/http://media.zenfs.com/en-US/homerun/people_218/4d82a5fa19dd37247717704975fdf602
https://www.google.com/about/main/machine-learning-qa/img/cat-dog-flow-horizontal.gif
https://www.google.com/trends/2014/static/images/pets-snapshot-reveal-1920.jpg
https://www.google.com/trends/2014/static/images/pets-share.png
https://www.google.com/about/main/machine-learning-qa/img/cat-dog-flow-vertical.gif
https://s.yimg.com/uu/api/res/1.2/YQWuQgTnzQuwXjYzX.QrWg--~B/aD0xMzMzO3c9MjAwMDtzbT0xO2FwcGlkPXl0YWNoeW9u/http://media.zenfs.com/en-US/homerun/people_218/4d82a5fa19dd37247717704975fdf602
https://www.google.com/trends/2014/static/images/pets-video-1080.jpg
https://www.google.com/trends/2014/static/images/pets-video-320.jpg
https://www.google.com/maps/d/thumbnail?mid=1hO0YkGLATyy-ZI9JxX1lbv-wK1M&hl=en_US
Run Code Online (Sandbox Code Playgroud)
我试图在Windows上安装hadoop,到目前为止它真的很麻烦.
这是我不断得到的错误
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (compile-ms-winutils) on project hadoop-common: Command execution failed. Cannot run program "msbuild" (in directory "C:\hdfs\hadoop-common-project\hadoop-common"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] …Run Code Online (Sandbox Code Playgroud) 我有一个从robobrowser发送到服务器的post请求,服务器响应没有数据,但响应头如下(这是Chrome浏览器的响应,它应该是这样的)
Cache-Control:no-cache, no-store, must-revalidate
Content-Length:335
Content-Type:application/json; charset=utf-8
Date:Wed, 02 Aug 2017 17:01:17 GMT
Expires:-1
lg:2673
Pragma:no-cache
Server:Unknown
Set-Cookie:BrandingUserLocationGroupID=ic4DUh/NXVp8VOKAtyDgbA==; expires=Fri, 01-Sep-2017 17:01:16 GMT; path=/; secure; HttpOnly
Set-Cookie:.AIRWATCHAUTH=A69C1A5EE8A5F3626385F35DA1B104EE7DFF5E5AF549DDB02EE8ED53931A0585C0FBB8299E3FC7B428A982B9826EF68390E659F4A74DCE00E195601F400D6E69F53907DADED4194F32DD08A72BA212DCCD0D23AB7C5BD56171E6C55EF1BE90849E9C81B2DAE23B05CA6E361326F44604; expires=Thu, 03-Aug-2017 17:01:17 GMT; path=/; secure; HttpOnly
Strict-Transport-Security:max-age=31536000;includeSubDomains
user:5679
X-Content-Type-Options:nosniff
x-download-options:noopen
x-frame-options:SAMEORIGIN
X-XSS-Protection:1; mode=block
Run Code Online (Sandbox Code Playgroud)
看起来服务器正在重置cookie,但我的robobrowser实例不响应/刷新新的cookie.基本上,网站试图切换会话/更改cookie我认为,但我的python robobrowser没有反映或不允许它由于某种原因改变
这是我的帖子请求和回复
browser=RoboBrowser()
browser.session.headers['X-Requested-With']='XMLHttpRequest'
browser.open('https://example.com/test/Users/set-role?id='+role_id+'&__RequestVerificationToken='+token,method='POST')
print browser.response.content
Run Code Online (Sandbox Code Playgroud)
这给了我错误响应如下
{"RedirectUrl":null,"IsSuccess":false,"Message":"Save Failed","CustomMessage":null,"Errors":[{"Key":"","Value":["An error has occurred. This error has automatically been saved for further analysis. Please contact technical support."]}],"Messages":{},"HasView":false,"ViewHtml":null,"ViewUrl":null,"IsValidationException":false,"IsValidationWarning":false,"ReloadPage":false,"IsSessionExpired":false,"Script":null,"NextWizardUrl":null,"PreviousWizardUrl":null,"ShowDialog":false}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何让robobrowser回应新的cookie?
非常感谢
我创建的以下方法似乎不起作用.在foreach循环中总会发生错误.
NotSupportedException未处理...提供程序不支持搜索,无法搜索WinNT:// WIN7,计算机.
我正在查询本地机器
private static void listUser(string computer)
{
using (DirectoryEntry d= new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer"))
{
DirectorySearcher ds = new DirectorySearcher(d);
ds.Filter = ("objectClass=user");
foreach (SearchResult s in ds.FindAll())
{
//display name of each user
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在快速学习并想知道在目录中列出所有具有绝对路径的文件的最佳方法是什么,包括来自子文件夹的文件(仅限文件)
我尝试了以下操作,但似乎列出了所有内容名称,甚至没有完整路径的文件夹名称。
let paths = FileManager.default.subpaths(atPath: folderPath)
for p in paths! {
print p
}
}
Run Code Online (Sandbox Code Playgroud)
也
let items = try fm.contentsOfDirectory(atPath: folderPath)
谷歌搜索没有提出任何工作方法。
这适用于 macOS 10.14
任何帮助表示赞赏!
谢谢
我有一个包含一些字符串的文本语料库.在这些字符串中,有些是英文单词,有些是随机的,如VmsVKmGMY6eQE4eMI,每个字符串中的字符数没有限制.
有没有办法测试一个字符串是否是英文单词?我正在寻找一种能够完成这项工作的算法.这是Java,我宁愿不实现额外的字典.
我试图了解如何super在python中使用
class people:
name = ''
age = 0
__weight = 0
def __init__(self,n,a,w):
self.name = n
self.age = a
self.__weight = w
def speak(self):
print("%s is speaking: I am %d years old" %(self.name,self.age))
class student(people):
grade = ''
def __init__(self,n,a,w,g):
#people.__init__(self,n,a,w)
super(student,self).__init__(self,n,a,w)
self.grade = g
def speak(self):
print("%s is speaking: I am %d years old,and I am in grade %d"%(self.name,self.age,self.grade))
s = student('ken',20,60,3)
s.speak()
Run Code Online (Sandbox Code Playgroud)
上面的代码出现以下错误:
---------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-147-9da355910141> in <module>()
10
11 …Run Code Online (Sandbox Code Playgroud) 我在VS2010中有一个带有statusStrip的简单windows窗体,无论我尝试什么,statusStrip的高度都不会改变,改变高度的正确方法是什么?
谢谢
对于具有负权重的有向图 G(V,E),我搜索了一些类似的主题,似乎贝尔曼福德可以检测负循环。但是一旦发现负循环就停止了,那么在这种情况下我们如何列出所有负循环呢?
考虑到埃里克·利珀特的建议,我尝试删除从图中发现的负循环,但我觉得这是不正确的,为什么?因为循环被删除后图形会发生变化,并且旧图形中可能存在额外的非负循环,但在新图形中不会找到。有人可以帮助我理清这个问题吗?
这可以用 java 或 c# 实现(不过我更喜欢 c#)
谢谢
c# ×4
python ×3
java ×2
python-2.7 ×2
python-3.x ×2
winforms ×2
algorithm ×1
apache ×1
cygwin ×1
data-mining ×1
directory ×1
file ×1
google-api ×1
hadoop ×1
http ×1
mapreduce ×1
maven ×1
recursion ×1
search ×1
statusstrip ×1
subprocess ×1
swift ×1
text ×1
text-mining ×1
urllib2 ×1