以下示例:
string1 = "calvin klein design dress calvin klein"
Run Code Online (Sandbox Code Playgroud)
我怎样才能删除第二个一式两份"calvin",并"klein"?
结果应该是这样的
string2 = "calvin klein design dress"
Run Code Online (Sandbox Code Playgroud)
只应删除第二个重复项,并且不应更改单词的顺序!
可能重复:
Python的Amazon API库?
我想使用python-amazon-product-api和lxml.objectify对Amazon产品API进行简单查询.
from amazonproduct import API
AWS_KEY = '..'
SECRET_KEY = '..'
api = API(AWS_KEY, SECRET_KEY, 'de')
node = api.item_search('Books', Publisher='Galileo Press')
# node object returned is a lxml.objectified element
# .pyval will convert the node content into int here
total_results = node.Items.TotalResults.pyval # <--- error
total_pages = node.Items.TotalPages.pyval
# get all books from result set and print author and title
for book in node.Items.Item:
print '%s: "%s"' % (book.ItemAttributes.Author, book.ItemAttributes.Title)
Run Code Online (Sandbox Code Playgroud)
错误信息:
AttributeError:'LxmlItemSearchPaginator'对象没有属性'Items'
lxml已正确安装!
哪里出错了?
如何通过在实际日期添加3天来设置jquery日期选择器的选定日期?
喜欢从11/01/2011到11/04/2011
我目前的代码不起作用!
<script type="text/javascript">
$(function() {$("#datepicker").datepicker();});
//Set DatePicker to actual date + 3 days
$('#dateselector').datepicker("setDate", new Date(date.getMonth()+"/"+(date.getDate()+3)+"/"+date.getFullYear()) );
</script>
Run Code Online (Sandbox Code Playgroud) 我想将设定日期的日期格式更改为"dd.mm.yy"!
对我来说,它应该像我的代码一样工作,但设置日期将显示"11/19/2011"代替"19.11.2011"
当我选择日期时,格式是正确的!
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
$('#datepicker').datepicker({ dateFormat: 'dd.mm.yy' });
$('#datepicker').datepicker("setDate", "+3");
});
/* German initialisation for the jQuery UI date picker plugin. */
jQuery(function($){
$.datepicker.regional['de'] = {
closeText: 'schließen',
prevText: '<zurück',
nextText: 'Vor>',
currentText: 'heute',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
weekHeader: 'Wo',
dateFormat: 'dd.mm.yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['de']);
});
</script>
Run Code Online (Sandbox Code Playgroud)