谜兔

文章 评论 浏览 29

谜兔 2025-02-19 23:46:05

您是否在 settings.py 中将 searchapp 添加到 installed_apps

您可能应该添加

'searchapp.apps.SearchappConfig',

installed_apps 中,就像这样:

INSTALLED_APPS = [
    'searchapp.apps.SearchappConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

Did you add searchapp to the INSTALLED_APPS in the settings.py?

You should probably add

'searchapp.apps.SearchappConfig',

into INSTALLED_APPS, like so:

INSTALLED_APPS = [
    'searchapp.apps.SearchappConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

如何删除“未解决的参考” pycharm中的错误我已经改变了Python的解释器,但不起作用

谜兔 2025-02-19 14:55:23

如果不更改库,并且不使用jQuery提供,则应该这样做(使用 JavaScript

setTimeout(function(){document.querySelectorAll("#selectedColumns button")[0].click();});

If without changing the library, and provided without use of JQuery, then this should do it (using Javascript)

setTimeout(function(){document.querySelectorAll("#selectedColumns button")[0].click();});

如何在AngularJS中自动打开NG-Dropdown-Multiselect?

谜兔 2025-02-19 09:45:26

您可以使用下面的脚本。注意的记录必须按ID进行排序!

CREATE TABLE #t2 ( ID int, Furnace_life INT, TopLife INT NULL);

INSERT INTO #t2
(
    ID,
    Furnace_life,
    TopLife
)
SELECT t.ID,t.Furnace_life,
      LAG(t.Furnace_life) OVER (ORDER BY t.ID) TopLife
    FROM #t1 t
ORDER BY ID


SELECT * FROM #t2 AS t WHERE t.Furnace_life = 1 AND t.TopLife IS NOT NULL

DROP TABLE #t1
DROP TABLE #t2

You can use below script. Note than records must be sorted by ID!

CREATE TABLE #t2 ( ID int, Furnace_life INT, TopLife INT NULL);

INSERT INTO #t2
(
    ID,
    Furnace_life,
    TopLife
)
SELECT t.ID,t.Furnace_life,
      LAG(t.Furnace_life) OVER (ORDER BY t.ID) TopLife
    FROM #t1 t
ORDER BY ID


SELECT * FROM #t2 AS t WHERE t.Furnace_life = 1 AND t.TopLife IS NOT NULL

DROP TABLE #t1
DROP TABLE #t2

如何在SQL中的1到下一个1之间获得最大NO

谜兔 2025-02-19 05:20:59

尝试用文字解释此代码。 “此功能返回两个值之一。如果输入为 a 。或输入是类型 b ,并且条件成立,则返回第一个。另一种条件否则,这是另一个值。对我来说,这听起来非常复杂。

我必须建议至少分解一点。至少,您有两个目标表达式,并且选择哪个取决于 value 的某些谓词。对我来说,这听起来像布尔值。假设 value 是某些特征类型 foo (哪个 a.type b 扩展),您可以

sealed trait Foo {
  def isFrobnicated: Boolean = this match {
    case A => true
    case B(_) if condition1 => true
    case _ => condition2
  }
}

...

if (value.isFrobnicated) {
  same expression
} else {
  different expression
}

立即 写入认知负载分为两个不同的较小的代码,以消化,并且大概 iSfrobnicated 将被给出一个自我记录的名称,以及一大片评论,解释了为什么这种区别很重要。任何阅读底部片段的人都可以简单地理解:“哦,有两个选择,基于杂语状态”,如果他们想要更多的详细信息,可以在 iSfrobnicated 文档中阅读一些可爱的散文。以及“ a b 的所有复杂性,如果此或其他任何事物都将“扔到了自己的功能中,则与其他所有内容分开。

如果 a b 没有您控制的常见supertype,则可以随时写一个独立的函数(如果您在Scala 3中)适当的扩展方法。选择你的选择。

根据您的实际用例,可能还可以做更多的事情,但这应该是一个开始。

Try to explain this code in words. "This function returns one of two values. The first is returned if the input is A. Or if the input is of type B and a condition holds. Oh, or if a different condition holds. Otherwise, it's the other value". That sounds incredibly complex to me.

I have to recommend breaking this down at least a bit. At minimum, you've got two target expressions, and which one is chosen depends on some predicate of value. That sounds like a Boolean to me. Assuming value is of some trait type Foo (which A.type and B extend), you could write

sealed trait Foo {
  def isFrobnicated: Boolean = this match {
    case A => true
    case B(_) if condition1 => true
    case _ => condition2
  }
}

...

if (value.isFrobnicated) {
  same expression
} else {
  different expression
}

Now the cognitive load is split into two different, smaller chunks of code to digest, and presumably isFrobnicated will be given a self-documenting name and a chunk of comments explaining why this distinction is important. Anyone reading the bottom snippet can simply understand "Oh, there's two options, based on the frobnication status", and if they want more details, there's some lovely prose they can go read in the isFrobnicated docs. And all of the complexity of "A or B if this or anything if that" is thrown into its own function, separate from everything else.

If A and B don't have a common supertype that you control, then you can always write a standalone function, an implicit class, or (if you're in Scala 3) a proper extension method. Take your pick.

Depending on your actual use case, there may be more that can be done, but this should be a start.

Scala匹配案例和多个分支

谜兔 2025-02-19 03:53:15

直接翻译就是这样:

proc sql;
create table GC_OUT.ABCD_2 as 
  select *
       , verify(ASSIGNED_EMPLOYEE_CD,"0") as index_first_non_zero
       , substr(ASSIGNED_EMPLOYEE_CD,calculated index_first_non_zero) 
         as ASSIGNED_EMPLOYEE_CD_1
  from GC_OUT.TEST
;
quit;

A direct translation would be something like this:

proc sql;
create table GC_OUT.ABCD_2 as 
  select *
       , verify(ASSIGNED_EMPLOYEE_CD,"0") as index_first_non_zero
       , substr(ASSIGNED_EMPLOYEE_CD,calculated index_first_non_zero) 
         as ASSIGNED_EMPLOYEE_CD_1
  from GC_OUT.TEST
;
quit;

如何将此SAS代码转换为SQL查询?

谜兔 2025-02-19 01:49:28

运行以下命令。

sudo npm intall -force

Run the following command.

sudo npm intall --force

VS代码在我的Linux NPM错误播种中不起作用?

谜兔 2025-02-18 16:53:44

您需要在模板中的儿童组件事件上做出反应并调用该方法。

import { Component } from '@angular/core';

@Component({
  selector: 'parent-component',
  template: `<child-component (onMessage)="printMessages(e)"></child-component>`,
  styleUrls: ['./parent.component.css']
})
export class ParentComponent {

  constructor() { }

  printMessages(event) { 
    // strings are included in event object
  }
}

You need to react on the child components event within the template and call the method.

import { Component } from '@angular/core';

@Component({
  selector: 'parent-component',
  template: `<child-component (onMessage)="printMessages(e)"></child-component>`,
  styleUrls: ['./parent.component.css']
})
export class ParentComponent {

  constructor() { }

  printMessages(event) { 
    // strings are included in event object
  }
}

Angular:如何使用EventEmitter将字符串值发送到另一个组件?

谜兔 2025-02-18 04:06:16

您无法创建主键,因为该列设置为允许零值。修改列以不允许空。

通过查询,它看起来应该像:

alter table PersonsTable alter column PersonID INT not null

You can't create a primary key because that column is set to allow null values. Modify the column to not allow nulls.

Via query, it should look something like:

alter table PersonsTable alter column PersonID INT not null

当我尝试添加主键时,为什么会遇到错误?

谜兔 2025-02-17 17:43:42

ICONDATA变量将再次设置为ICONS.GRID_VIEW,每次您调用SET状态(如果将其放置在构建方法中),请在构建方法之外声明它

class _AppsScreenState extends State<AppsScreen> {
  late Future<AllApps> activateApps;
  IconData iconData = Icons.grid_view;

  @override
  void initState() {
    super.initState();
    activateApps = getActivatedApps();
  }

  @override
  Widget build(BuildContext context) {

    void _toggleViewIcon() {
      setState(() {
        if (iconData == Icons.grid_view) {
          iconData = Icons.list;
        } else {
          iconData = Icons.grid_view;
        }
      });
    }

    return Scaffold(
        appBar: AppBar(
          title: const Text('Apps'),
          primary: false,
          toolbarHeight: 50,
          leading: IconButton(
            tooltip: 'Toggle view',
            icon: Icon(iconData),
            onPressed: _toggleViewIcon,
          ),
          actions: <Widget>[
            Padding(
                padding: const EdgeInsets.only(right: 20.0),
                child: IconButton(
                  tooltip: 'Refresh',
                  icon: const Icon(Icons.refresh),
                  onPressed: () {
                    setState(() {
                      activateApps = getActivatedApps();
                    });
                  },
                )),
            Padding(
                padding: const EdgeInsets.only(right: 20.0),
                child: IconButton(
                  tooltip: 'Add or remove apps',
                  icon: const Icon(Icons.add),
                  onPressed: () {
                    setState(() {
                      activateApps = getActivatedApps();
                    });
                  },
                )),
          ],
        ),
        primary: false,
        body: Column(children: []));
  }
}

iconData variable will be set again to Icons.grid_view each time when you call set state if it put inside build method, so declare it outside build method

class _AppsScreenState extends State<AppsScreen> {
  late Future<AllApps> activateApps;
  IconData iconData = Icons.grid_view;

  @override
  void initState() {
    super.initState();
    activateApps = getActivatedApps();
  }

  @override
  Widget build(BuildContext context) {

    void _toggleViewIcon() {
      setState(() {
        if (iconData == Icons.grid_view) {
          iconData = Icons.list;
        } else {
          iconData = Icons.grid_view;
        }
      });
    }

    return Scaffold(
        appBar: AppBar(
          title: const Text('Apps'),
          primary: false,
          toolbarHeight: 50,
          leading: IconButton(
            tooltip: 'Toggle view',
            icon: Icon(iconData),
            onPressed: _toggleViewIcon,
          ),
          actions: <Widget>[
            Padding(
                padding: const EdgeInsets.only(right: 20.0),
                child: IconButton(
                  tooltip: 'Refresh',
                  icon: const Icon(Icons.refresh),
                  onPressed: () {
                    setState(() {
                      activateApps = getActivatedApps();
                    });
                  },
                )),
            Padding(
                padding: const EdgeInsets.only(right: 20.0),
                child: IconButton(
                  tooltip: 'Add or remove apps',
                  icon: const Icon(Icons.add),
                  onPressed: () {
                    setState(() {
                      activateApps = getActivatedApps();
                    });
                  },
                )),
          ],
        ),
        primary: false,
        body: Column(children: []));
  }
}

在Iconbutton中切换图标

谜兔 2025-02-17 11:25:21

看起来您选择了一条漫长的道路。我不会去那里。

我将考虑尝试缩小在分析之前的代码。要完全消除可变名称的任何影响,额外的间距,格式化甚至略有逻辑改组。

另一种方法是比较 byte-byte-code 。但这可能不是一个好主意,因为结果可能还必须额外清理。

dis 是一个有趣的选择。

我很可能会停止比较他们的 ast 。但是AST可能会给短期功能提供误报。因为它们的结构可能太相似了,因此请考虑使用其他一些东西检查简短的功能。

在thaaaat的顶部,我会考虑使用 levenshtein距离或类似于数值的差异在学生的字节代码/来源/AST/DIS之间。这是什么?几乎是O(n^2)?没关系。

或者,如果需要,使其更加复杂,并计算学生A的每个功能与学生B的每个功能之间的距离,从而突出显示距离太短的情况。不过可能不需要。

随着输入的简化和归一化,更多的算法应开始返回良好的结果。如果一个学生足够好,可以拿走某人的代码并重新装修变量,而且可以改善逻辑,甚至可以改善算法,那么该学生将足够理解代码以捍卫它并在将来没有帮助的情况下使用它。我想,这就是老师希望在学生之间交换的帮助。

Looks like you're choosing a long path. I wouldn't go there.

I would look into trying to minify the code before analyzing it. To completely remove any influence of variable names, extra spacing, formatting and even slight logic reshuffling.

Another approach would be comparing byte-code of the students. But it may be not a very good idea since the result will likely have to be additionally cleaned up.

Dis would be an interesting option.

I would, most likely, stop on comparing their AST. But ast is likely to give false positives for short functions. Cuz their structure may be too similar, so consider checking short functions with something else, something trivial.

On top of thaaaat, I would consider using Levenshtein distance or something similar to numerically calculate the differences between byte-codes/sources/ast/dis of the students. This would be what? Almost O(N^2)? Shouldn't matter.

Or, if needed, make it more complex and calculate the distance between each function of student A and each function of student B, highlighting cases when the distance is too short. It may be not needed though.

With simplification and normalization of the input, more algorithms should start returning good results. If a student is good enough to take someone's code and reshuffle not only the variables, but the logic and maybe even improve the algo, then this student understands the code well enough to defend it and use it with no help in future. I guess, that's the kind of help a teacher would want to be exchanged between students.

如何检测文本文件中几乎重复的数量?

谜兔 2025-02-17 10:50:29

这是一个选项,可以使用动态sql

示例或 无需 ;小提琴= AA4A8CE42F7C2FB157D90FE43E570AA8“ rel =“ nofollow noreferrer”> dbfiddle

Select A.ID
      ,B.*
 From YourTable A
 Cross Apply (
               Select Rank1 = max(case when Rnk=1 then [Key] end)
                     ,Rank2 = max(case when Rnk=2 then [Key] end)
                     ,Rank3 = max(case when Rnk=3 then [Key] end)
                 From (
                        Select [Key]
                              ,Value
                              ,Rnk = row_number() over (order by convert(int,value) desc)
                         From OpenJson((Select A.* For JSON Path,Without_Array_Wrapper )) 
                         Where [Key] Not IN( 'ID','Other','Columns','ToExclude')
                      ) B1
             ) B

Here is an option that will dynamically unpivot your data WITHOUT using Dynamic SQL

Example or dbFiddle

Select A.ID
      ,B.*
 From YourTable A
 Cross Apply (
               Select Rank1 = max(case when Rnk=1 then [Key] end)
                     ,Rank2 = max(case when Rnk=2 then [Key] end)
                     ,Rank3 = max(case when Rnk=3 then [Key] end)
                 From (
                        Select [Key]
                              ,Value
                              ,Rnk = row_number() over (order by convert(int,value) desc)
                         From OpenJson((Select A.* For JSON Path,Without_Array_Wrapper )) 
                         Where [Key] Not IN( 'ID','Other','Columns','ToExclude')
                      ) B1
             ) B

TSQL-等级值但返回列名称

谜兔 2025-02-17 07:42:16

谢谢我使用的所有使用openssl命令在Python中解密文件

decrypted_data = subprocess.check_output(
            f'echo "{encryptedtext}" | openssl cms -decrypt -inkey services/private_key_no_pass.pem -inform PEM ',
            shell=True)

Thanks all I have used openssl commands to decrypt file in python

decrypted_data = subprocess.check_output(
            f'echo "{encryptedtext}" | openssl cms -decrypt -inkey services/private_key_no_pass.pem -inform PEM ',
            shell=True)

我可以使用任何依赖性解密OPENSSL加密数据吗?

谜兔 2025-02-17 04:00:44

您可以使用 ord()内置函数并列表理解,以创建所需的功能,如下所示:

x = "Villalobos Velasquez Santiago"

def fun(s):
    out = 0
    for i in s.lower():
        if i != " ":
            out += (ord(i)-96)
    return out

print(fun(x))

output:

333

You can use ord() built-in function and list comprehension to create the function you need as follows:

x = "Villalobos Velasquez Santiago"

def fun(s):
    out = 0
    for i in s.lower():
        if i != " ":
            out += (ord(i)-96)
    return out

print(fun(x))

Output:

333

我正在尝试创建一个输入名称并输出等级的函数。创建该功能的最佳方法是什么?

谜兔 2025-02-17 01:46:04

我认为您应该使用导入日志记录,而不是导入记录器或未安装的记录仪。您可以通过PIP安装记录器或记录IDK

 def someMethod(self):
        logger.info ('about to do something useful')

在定义时结尾应具有一个结肠

I think your supposed to use import logging not import logger or you havent installed logger. you can do this by pip install logger or logging idk

 def someMethod(self):
        logger.info ('about to do something useful')

should have a colon at the end when it is defined

python名称空间:避免将符号强加于全球

谜兔 2025-02-16 21:13:26

我确实喜欢这样做。

setAS = BGPPathAttr(
    type_flags="Transitive",
    type_code="AS_PATH",
    attr_len=None,
    attribute=BGPPAAS4BytesPath(
        segments=BGPPAAS4BytesPath().ASPathSegment(
                                                    segment_type=2(AS_SEQUENCE), segment_length=None, segment_value=[1234]
                                                )
                                )
    )

当我们有变量询问“长度” 时,请使用“无”

I did like this and works.

setAS = BGPPathAttr(
    type_flags="Transitive",
    type_code="AS_PATH",
    attr_len=None,
    attribute=BGPPAAS4BytesPath(
        segments=BGPPAAS4BytesPath().ASPathSegment(
                                                    segment_type=2(AS_SEQUENCE), segment_length=None, segment_value=[1234]
                                                )
                                )
    )

When we have variables asking the "length", please use "None".

如何在BGP的Scapy中使用as_path属性?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文