我有一本字典
a = {'ground': obj1, 'floor 1': obj2, 'basement': obj3}
Run Code Online (Sandbox Code Playgroud)
我有一份清单.
a_list = ['floor 1', 'ground', 'basement']
Run Code Online (Sandbox Code Playgroud)
我想基于列表使用其键对字典a进行排序.有可能吗?
即:
sort(a).based_on(a_list) #this is wrong. But I want something like this.
Run Code Online (Sandbox Code Playgroud)
输出不必是另一个字典,我不介意将字典转换为元组然后对它们进行排序.
我想使用 django 1.9 使用通用类基视图 我想理解的是
from django.views.generic import CreateView
from braces.views import LoginRequiredMixin
from .models import Invoice
class InvoiceCreateView(LoginRequiredMixin,CreateView):
model = Invoice
def generate_invoice(self):
...
return invoice
Run Code Online (Sandbox Code Playgroud)
现在我想将此自定义方法绑定到 url。我怎样才能做到这一点?我知道使用函数基视图很简单,但我想使用类基视图来做到这一点。
帮助将不胜感激。
I am trying to select a few words from the textarea and create bootstrap chips.
I am able to create the chips for selected words. I am trying to highlight the selected words with different background colors.
export class SearchComponent implements OnInit {
constructor() { }
selectedText = [];
regexFromMyArray: RegExp;
// tslint:disable-next-line:typedef
showSelectedText() {
let text = '';
if (window.getSelection) {
text = window.getSelection().toString();
if (text) {
// console.log(this.selectedText.includes(text));
if (this.selectedText.includes(text) === false)
{
this.selectedText.push(text);
this.regexFromMyArray = new RegExp(this.selectedText.join('|'), …Run Code Online (Sandbox Code Playgroud) python ×2
angular ×1
angular8 ×1
dictionary ×1
django ×1
javascript ×1
list ×1
sorting ×1
textarea ×1