给出2个列表:
a = [3,4,5,5,5,6]
b = [1,3,4,4,5,5,6,7]
Run Code Online (Sandbox Code Playgroud)
我想找到"重叠":
c = [3,4,5,5,6]
Run Code Online (Sandbox Code Playgroud)
我也喜欢它,如果我可以提取"剩余"部分a和b不在c中.
a_remainder = [5,]
b_remainder = [1,4,7,]
Run Code Online (Sandbox Code Playgroud)
注意:a中有三个5,b有两个.b里面有两个4,有一个.
结果列表c应该有两个5(由列表b限制)和一个4(由列表a限制).
这给了我想要的东西,但我不禁想到有更好的方法.
import copy
a = [3,4,5,5,5,6]
b = [1,3,4,4,5,5,6,7]
c = []
for elem in copy.deepcopy(a):
if elem in b:
a.pop(a.index(elem))
c.append(b.pop(b.index(elem)))
# now a and b both contain the "remainders" and c contains the "overlap"
Run Code Online (Sandbox Code Playgroud)
另一方面,对于我要求的是什么比"重叠"和"剩余"更准确的名称?
我想在我的iOS应用程序中创建一个与tiff文件关联的文件(即,以便我的应用程序显示为从Mail或Safari打开tiff文件的目标).将以下内容添加到我的Info.plist文件似乎不起作用:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>tiff</string>
<key>LSItemContentTypes</key>
<array>
<string>public.tiff</string>
</array>
<key>LSHandlerRank</key>
<string>Alternate</string>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
我有一个应用程序,我以相同的方式与PDF相关联,它工作正常.我认为不可能将应用程序与iOS上的tiff文件类型相关联,但我找不到任何说明这一点的文档.
有没有其他人幸运地得到这个工作或找到一个明确的"不,你不能这样做"?
我运行我的应用程序时遇到了这个异常.它也发生在真正的Azure blob存储中.
我已经抓住了Fiddler创建此问题的请求:
GET http://127.0.0.1:10000/devstoreaccount1/ebb413ed-fdb5-49f2-a5ac-74faa7e2d3bf/8844c3ec-9e4b-43ec-88b2-58eddf65fc0a/perro?timeout=90 HTTP/1.1
x-ms-version: 2009-09-19
User-Agent: WA-Storage/6.0.6002.18006
x-ms-range: bytes=0-524304
If-Match: 0x8CDA190BD304DD0
x-ms-date: Wed, 23 Feb 2011 16:49:18 GMT
Authorization: SharedKey devstoreaccount1:5j3IScY9UJLN3o1ICWKwVEazO4/IDJG796sdZKqHlR4=
Host: 127.0.0.1:10000
Run Code Online (Sandbox Code Playgroud)
这是回应:
HTTP/1.1 412 The condition specified using HTTP conditional header(s) is not met.
Content-Length: 252
Content-Type: application/xml
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: fbff9d15-65c8-4f21-9088-c95e4496c62c
x-ms-version: 2009-09-19
Date: Wed, 23 Feb 2011 16:49:18 GMT
<?xml version="1.0" encoding="utf-8"?><Error><Code>ConditionNotMet</Code><Message>The condition specified using HTTP conditional header(s) is not met.
RequestId:fbff9d15-65c8-4f21-9088-c95e4496c62c
Time:2011-02-23T16:49:18.8790478Z</Message></Error>
Run Code Online (Sandbox Code Playgroud)
当我使用从此行检索的Stream时会发生这种情况:
blob.OpenRead();
Run Code Online (Sandbox Code Playgroud)
为什么ETAG会在读操作中介意?我怎么能避免这个问题?
每次我在blob存储上启动多个并行任务时都会发生这种情况.
如果我使用:
blob.OpenRead(new BlobRequestOptions() { AccessCondition …Run Code Online (Sandbox Code Playgroud) 我有清单 - Sep1:
[
....
["Message-ID", "AAAAAAAAAAAAAAAAAAA"],
["To", "BBBBBBBBBBBBBBBBB"]
...
]
Run Code Online (Sandbox Code Playgroud)
我尝试获取第一项= Message_ID的元素,例如:
lists:filter(fun(Y) -> (lists:nth(1,lists:nth(1,Y)) =:= "Message-ID") end, Sep1).
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
exception error: no function clause matching lists:nth(1,[])
in function utils:'-parse_to/1-fun-1-'/1
in call from lists:'-filter/2-lc$^0/1-0-'/2
Run Code Online (Sandbox Code Playgroud)
但如果我:
io:format(lists:nth(1,lists:nth(1,Sep1))).
> Message-ID
Run Code Online (Sandbox Code Playgroud)
怎么了?
谢谢.
html/css:
<style>
div.myWords p { display: hidden; }
p.show { display: block; }
</style>
<div class="myWords">
<p>Hello</p>
<p>Hola</p>
<p>Bonjour</p>
</div><!-- myWords -->
Run Code Online (Sandbox Code Playgroud)
如何<p>在文档就绪时随机将"show"类添加到单个元素中?
换句话说,每次加载页面时都应该看到1个p标签,并且应该随机选择该p标签.
我正在使用Jackson示例代码反序列化POJO:
ObjectMapper m = new ObjectMapper();
Run Code Online (Sandbox Code Playgroud)
该行抛出NoSuchMethodError:
Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.<init>(Ljava/lang/Class;)V
at org.codehaus.jackson.map.type.TypeBase.<init>(TypeBase.java:15)
at org.codehaus.jackson.map.type.SimpleType.<init>(SimpleType.java:45)
at org.codehaus.jackson.map.type.SimpleType.<init>(SimpleType.java:40)
at org.codehaus.jackson.map.type.TypeBindings.<clinit>(TypeBindings.java:18)
at org.codehaus.jackson.map.type.TypeFactory._fromType(TypeFactory.java:525)
at org.codehaus.jackson.map.type.TypeFactory.type(TypeFactory.java:61)
at org.codehaus.jackson.map.ObjectMapper.<clinit>(ObjectMapper.java:179)
at com.me.util.ctrl.BillingJobStatus.fromJson(BillingJobStatus.java:37)
Run Code Online (Sandbox Code Playgroud)
我不明白
我继承了一个旧的 VB.net 项目。代码主要使用 try-catch 进行错误处理。但是在某些地方我发现If Err.Number <> 0 Then.
如果发生错误,是什么决定是Exception应该抛出an还是只设置Err?
我不想同时处理错误...
我正在通过实际潜入它来学习C#.我刚刚停了下来.我在下面有这个代码有一个菜单项,Acquire.当我选择它时,它会运行Acquire.但是我希望它在加载/启动应用程序后立即运行.
我在哪里做出必要的改变?
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Runtime.InteropServices;
using WIALib; // namespace of imported WIA Scripting COM component
namespace Wia
{
/// <summary> MainForm for this WIA sample </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu;
private System.Windows.Forms.MenuItem menuTopFile;
private System.Windows.Forms.MenuItem menuFileAcquire;
private System.Windows.Forms.MenuItem menuFileSaveAs;
private System.Windows.Forms.MenuItem menuFileSep1;
private System.Windows.Forms.MenuItem menuFileExit;
private System.Windows.Forms.PictureBox pictureBox;
private IContainer components;
public MainForm()
{
//
// Required for Windows Form Designer support …Run Code Online (Sandbox Code Playgroud) 我按照http://developer.android.com/guide/topics/search/search-dialog.html上描述的步骤在我的记事本应用程序中实现搜索功能.
我的问题是,当我完成搜索时,新的活动会打开捕获我的搜索查询.但我真正想要的是,查询返回到当前活动而不是开始新活动.
这可能吗?
更新:
AndroidManifest.xml中
<activity android:name="MyNotepad"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.SEARCH"></action>
</intent-filter>
<meta-data android:resource="@xml/searchable" android:name="android.app.searchable"></meta-data>
</activity><activity android:name="Preferences" android:label="Preferences" >
</activity>
searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable
xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="@string/search_hint">
</searchable>
JAVA代码
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_pad);
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
Toast.makeText(getApplicationContext(), query, Toast.LENGTH_LONG).show();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case R.id.menuItemSearch:
startSearch("", false, null, false);
break;
}
return true; …Run Code Online (Sandbox Code Playgroud)