我有一个这样的列表:
all = [[a,b,c,d],[r,d,g,s],[e,r,a,b],[p,o,i,u]....(more similar items)]
Run Code Online (Sandbox Code Playgroud)
我想有多少个项目是其中一样的,所以我需要比较all[0]
用all[1],all[2]...all[(len(all)-1)]
,然后用all[1]
与比较all[2],all[3]...all[(len(all)-1)]
,然后all[2]
与比较all[3],all[4],...all[(len(all)-1)]
我试过这样的事情:
for i in range(len(all)):
print len(all[i] & all[i+1]) ##how many identical items shared by all[0] and all[1]
print len(all[i+1] & all[i+2])
Run Code Online (Sandbox Code Playgroud)
但不知道如何继续,我想得到的结果是:
item1 has 3 same values with item2,
has 4 same values with item3,
has 1 same values with item4....
item2 has 3 same values with item1,
has 2 same values with item3,
etc
Run Code Online (Sandbox Code Playgroud) 我有一个表tbl_jobs
,它存储在应用程序中运行的一些后台作业的元数据.架构如下:
CREATE TABLE `tbl_jobs` (
`type` varchar(30) NOT NULL DEFAULT '',
`last_run_on` datetime NOT NULL,
`records_updated` text,
PRIMARY KEY (`type`,`last_run_on`),
UNIQUE KEY `index2` (`type`,`last_run_on`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$
Run Code Online (Sandbox Code Playgroud)
每当作业运行时,它在表中创建一个条目,该条目type
是不同作业的唯一标识符,run time
并且records updated
在该运行中.
有两种不同的作业同时运行类型:MAILER_UNLOCKED_REWARDS
和MAILER_ALMOST_UNLOCKED
.
当这些作业尝试使用相同的时间戳插入其条目时,只会插入其中一个,而另一个会因为键错误而引发重复条目.
例如,这两个工作运行如下:
INSERT INTO tbl_jobs
(type,
last_run_on,
records_updated)
VALUES ('MAILER_ALMOST_UNLOCKED',
'2012-08-22 19:10:00',
'f8a35230fb214989ac75bf11c085aa28:b591426df4f340ecbce5a63c2a5a0174')
Run Code Online (Sandbox Code Playgroud)
运行成功,但第二个作业运行插入命令
INSERT INTO tbl_jobs
(type,
last_run_on,
records_updated)
VALUES ('MAILER_UNLOCKED_REWARDS',
'2012-08-22 19:10:00',
'8a003e8934c07f040134c30959c40009:59bcc21b33a0466e8e5dc50443beb945')
Run Code Online (Sandbox Code Playgroud)
它抛出了错误
Duplicate entry 'M-2012-08-22 19:10:00' for key …
Run Code Online (Sandbox Code Playgroud) 在我使用的各种SQL产品中,问号(?)标记查询中的输入参数.
如何逃避该行为并搜索包含问号的文本,例如......
SELECT *
FROM A_TABLE
WHERE A_FIELD = 'This is a question mark not an input parameter?'
Run Code Online (Sandbox Code Playgroud)
...上面的问号是字面问号,而不是占位符.如果答案是产品特定的,我目前正在使用Derby(又名Java DB).
//expiration
$datetoday = date("F j, Y, G:i");
$expquery = mysql_query("SELECT a_expire FROM regform_admin WHERE status = 'Pending for payment'");
$row = mysql_fetch_array($expquery);
$expirydate = $row['a_expire'];
echo "$datetoday";
echo "$expirydate";
if ($datetoday == $expirydate) {
$expirequery = mysql_query("UPDATE regform_admin SET status = 'Expired' WHERE status = 'Pending'");
$expirequery2 = mysql_query("UPDATE regform SET status = 'Expired' WHERE status = 'Pending'");
}
//end expiration
Run Code Online (Sandbox Code Playgroud)
嗨,我的预订代码到期了.我的问题是,如果客户在23:30预订并且预订将在00:30(1小时)到期,我制作了以下代码:
$currentdate = date("F j, Y, G:i");
$onehour = date("G") + 1;
$expire = date("F j, Y, $onehour:i");
Run Code Online (Sandbox Code Playgroud)
在 …
我是Java EE中的新手,我想知道以下哪个会执行更快,Javascript或用servlet编写的代码?
上下文:电子邮件字段上的正则表达式验
我在一个nodejs
项目中使用玉
找不到如何定义过滤器
我有类别,我想在选择框,小写选项值和大写选项文本中显示
select
each cat in categories
option(value="lowercase(#{cat})") uppercase(#{cat})
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
我从 Web 服务调用中得到了以下响应,我尝试使用 JAXB 对其进行解组以将其映射到 Java 类。这样做时我遇到了解组异常。
<?xml version="1.0" encoding="UTF-8"?>
<ns0:QueryByLNResponse xmlns:ns0="UIS_CTMPeople_WS" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:getListValues>
<ns0:First_Name>Pradeep</ns0:First_Name>
<ns0:Internet_E-mail/>
<ns0:ManagersName/>
<ns0:Person_ID>PPL1</ns0:Person_ID>
<ns0:Last_Name>Srinivasa Reddy</ns0:Last_Name>
<ns0:Full_Name>Pradeep M Srinivasa Reddy</ns0:Full_Name>
</ns0:getListValues>
<ns0:getListValues>
<ns0:First_Name>Geeth </ns0:First_Name>
<ns0:Internet_E-mail>bas@yahoo.com</ns0:Internet_E-mail>
<ns0:ManagersName/>
<ns0:Person_ID>PPL2</ns0:Person_ID>
<ns0:Last_Name>Srinivasan</ns0:Last_Name>
<ns0:Full_Name>Geeth Srinivasan</ns0:Full_Name>
</ns0:getListValues>
</ns0:QueryByLNResponse>
Run Code Online (Sandbox Code Playgroud)
我尝试使用解组上述代码
public static Object xmlToObject(String xml, Class... objClass) throws Exception {
JAXBContext jc = JAXBContext.newInstance(objClass);
final Unmarshaller unmarshaller = jc.createUnmarshaller();
return unmarshaller.unmarshal(new StringReader(xml.toString()));
}
Run Code Online (Sandbox Code Playgroud)
它抛出以下错误
javax.xml.bind.UnmarshalException: unexpected element (uri:"UIS_CTMPeople_WS", local:"QueryByLNeResponse"). Expected elements are (none)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Unknown …
Run Code Online (Sandbox Code Playgroud) 我已经为特定的应用需求创建了一个MOJO.我已经遵循maven的指导命名插件,所以我没有提到完整
mvn groupId:artifactId:version:goal
Run Code Online (Sandbox Code Playgroud)
用于执行我的插件(我将其命名为匹配格式$ {prefix} -maven-plugin).我甚至在插件POM的配置部分中包含了'goalPrefix'属性.以下是我对插件的POM所做的嗅探:
<configuration>
<goalPrefix>${prefix}</goalPrefix>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但我仍然无法执行我的插件,mvn ${prefix}:goal
因为它抱怨它无法在任何存储库中找到插件.我仍然不得不使用mvn groupId:artifactId:version:goal
任何想法为什么?
好!首先,这个问题来自于一个在jQuery世界中挖掘太深(并且可能会迷路)的人.
在我的研究中,我发现jquery的主要模式是这样的(如果需要更正是很好的):
(function (window, undefined) {
jQuery = function (arg) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init(arg);
},
jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function (selector, context, rootjQuery) {
// get the selected DOM el.
// and returns an array
},
method: function () {
doSomeThing();
return this;
},
method2: function () {
doSomeThing();
return this;,
method3: function () {
doSomeThing();
return this;
};
jQuery.fn.init.prototype = jQuery.fn;
jQuery.extend = jQuery.fn.extend …
Run Code Online (Sandbox Code Playgroud) javascript ×2
css ×1
duplicates ×1
filter ×1
java-ee ×1
jaxb ×1
jquery ×1
maven ×1
mysql ×1
namespaces ×1
node.js ×1
oop ×1
php ×1
primary-key ×1
pug ×1
python ×1
sql ×1
templates ×1