神仙妹妹

文章 评论 浏览 28

神仙妹妹 2025-02-20 19:05:53

以下代码将以您想要的方式提取单词:

import re

words = re.compile(r'\w+\[?-?\d*\]?', re.IGNORECASE)
s = 'orange,juices,apple,apple[-2],pineapple[20]'

words.findall(s)

这将导致以下内容:

['orange', 'juices', 'apple', 'apple[-2]', 'pineapple[20]']

请记住,上面的摘要是用您提供的示例字符串编写的。如果您需要匹配其他类型的单词(例如, 007%ABC ),则需要调整正则表达式以匹配更多字符。

The following code will extract the words the way you want:

import re

words = re.compile(r'\w+\[?-?\d*\]?', re.IGNORECASE)
s = 'orange,juices,apple,apple[-2],pineapple[20]'

words.findall(s)

Which will result in the following:

['orange', 'juices', 'apple', 'apple[-2]', 'pineapple[20]']

Bear in mind that the snippet above was written with the example string you provided as the base. If you need to match other types of words (007%abc, for example), you will need to adjust the regular expression to match more characters.

正则表达式匹配单词,然后是一对括号

神仙妹妹 2025-02-20 14:43:43

TCP堆栈中是否有超时?

TCP堆栈中有许多不同的超时,具体取决于我们当前处于哪种状态以及如何配置连接(例如,是否使用keepalive)。似乎没有定义空闲连接超时(这是您所指的)。使用Keepalive,超时为2小时。话虽如此,世界上每个防火墙几乎都会暂停。基于此reddit thread 15分钟看起来像一个合理的假设,是一个合理的假设,甚至1小时。但是多天?我怀疑它将在任何网络中都活着(除了您自己的)。

NetCat(或操作系统)是否发送一些数据包以保持连接?

否。您将必须通过发送数据来自己做。有了TCP的KeepAlive选项,OS将为您执行此操作(注意:默认情况下禁用了keepalive),但是这可以在直接同行之间起作用,即涉及代理时可能会失败。发送数据绝对是一种更好的方法。

Is there a timeout in tcp stack ?

There are many different timeouts in the TCP stack, depending on what state we are currently in, and how the connection was configured (e.g. with keepalive or not). The idle connection timeout (which is what you refer to) does not seem to be defined. With keepalive the timeout is ~2 hours. That being said pretty much every firewall in the world will setup some timeout. Based on this reddit thread 15 minutes looks like a reasonable assumption, maybe even 1 hour. But multiple days? I doubt it will be alive in any network (except your own).

Does netcat (or operating system) sends some packets to keep the connection opened ?

No. You will have to do it yourself by sending data. With the keepalive option for TCP, the OS will do it for you (note: keepalive is disabled by default), but this works between direct peers, i.e. may fail when proxies are involved. Sending data is definitely a better approach.

保持TCP连接打开的数据成本

神仙妹妹 2025-02-20 14:36:04
[queryParams]="{param1:['value1', 'value2']}"

您可以这样做,但是您会得到这样的数组

constructor(
    private ar: ActivatedRoute
  ) { }

  ngOnInit(): void {
    this.ar.queryParams.subscribe((params) => {
      console.log(params) // ['value1', 'value2']
    })
  }
[queryParams]="{param1:['value1', 'value2']}"

You can do it like this but you will get an array like this

constructor(
    private ar: ActivatedRoute
  ) { }

  ngOnInit(): void {
    this.ar.queryParams.subscribe((params) => {
      console.log(params) // ['value1', 'value2']
    })
  }

在角度指定参数的多个值

神仙妹妹 2025-02-20 03:26:10

NetworkX shell_layout 用于节点位置& 选择了graphViz neato 用于边路路由

neato 之所以选择,因为它尊重graphviz节点属性 pos pin> pin

使用 splines edge edge and attribute and attribute esep 可以避免边缘节点交叉。

import networkx as nx
import pygraphviz as pgv
from math import log

G = nx.read_graphml('ITC_2_012_idx8.graphml')

indices = set([idx for n, idx in G.nodes.data('index')])
radii = [log(idx)/log(max(indices)) for n, idx in G.nodes.data('index')]
shells = [[n for n, idx in G.nodes.data('index') if idx == x] for x in indices]
pos = nx.shell_layout(G, shells)

A = nx.nx_agraph.to_agraph(G)

A.graph_attr['splines'] = 'spline' # or 'polyline'
A.graph_attr['scale'] = '0.6'
A.graph_attr['esep'] = '0.5' # node-edge distance
A.node_attr['shape'] = 'circle'
A.node_attr['pin'] = 'true'
for k in A.nodes():
    n = A.get_node(k)
    n.attr['label'] = str(n.attr['index']) # add label 
    n.attr['pos'] = str(pos[k][0]*10)+','+str(pos[k][1]*10)+'!' # set pos string 
    
# print(A.to_string())

A.layout() # default 'neato' which respects the node attribute 'pos'
A # rich output in Jupyter Notebook/Lab using pygraphviz 1.9, Feb 2022

边缘节点交叉点已经消失。

但是,该解决方案尚未像我想拥有的那样:
我更喜欢入站和出站边缘在相对站点的节点上停靠(根节点除外)。
带有边路路由的YED径向布局可以做到这一点,或者查看我的低分辨率自制布局和路由。

更新:Enforce tailport

import networkx as nx
import pygraphviz as pgv
from math import atan2, log, pi

G = nx.read_graphml("ITC_2_012_idx8.graphml")
indices = set([int(idx) for n, idx in G.nodes.data('index')])
radii = [log(idx)/log(max(indices)) for n, idx in G.nodes.data('index')]
shells = [[n for n, idx in G.nodes.data('index') if idx == x] for x in indices]
pos = nx.shell_layout(G, shells)

A = nx.nx_agraph.to_agraph(G)

pos_factor = 12
A.graph_attr['scale'] = "0.5"
A.graph_attr['esep'] = "1"
A.graph_attr['splines'] = "spline"
A.node_attr['shape'] = "circle"
A.node_attr['pin'] = "true"
A.edge_attr['arrowhead']="vee"
for k in A.nodes():
    k.attr["label"] = str(k.attr["index"]) 
    k.attr["pos"] = str(pos[k][0]*pos_factor)+','+str(pos[k][1]*pos_factor)+"!" 

# Set 'tailport' based on quadrant of tail node 
for n1, n2 in A.edges():
    if n1 == A.nodes()[0]: # skip root edges
        continue
    e = A.get_edge(n1, n2)
    theta = atan2(pos[n1][1], pos[n1][0])/pi*180.
    
    if -22.5 <= theta < 22.5:
        e.attr["tailport"] = 'e'
    elif 22.5 <= theta < 67.5:
        e.attr["tailport"] = 'ne'
    elif 67.5 <= theta < 112.5:
        e.attr["tailport"] = 'n'
    elif 112.5 <= theta < 157.5:
        e.attr["tailport"] = 'nw'
    elif 157.5 <= theta <= 180. or -157.5 > theta > -180.:
        e.attr["tailport"] = 'w'
    elif -157.5 <= theta <= -112.5:
        e.attr["tailport"] = 'sw'
    elif -112.5 <= theta <= -67.5:
        e.attr["tailport"] = 's'
    elif -67.5 <= theta <= -22.5:
        e.attr["tailport"] = 'se'
    else:
        raise ValueError('Quadrant determination failed for node', n1,
                         'with polar angle', theta)
    
# Mark problematic edges
A.get_edge('10', '14').attr["color"] = "red"
A.get_edge('04', '06').attr["color"] = "blue"
A.get_edge('06', '18').attr["color"] = "orange"

A.layout() # default 'neato'
A

“在此处输入图像描述”

但是,以imho可视化并不清楚(易于掌握连接性),因为某些高度弯曲引入边缘(例如红色),并存在平行边缘重叠(例如蓝色和橙色)。

NetworkX shell_layout for node positions & GraphViz neato for edge routing

Neato is chosen because it respects the graphviz node attribute pos in combination with pin.

With splines edge routing and the attribute esep, edge-node crossings can be avoided.

import networkx as nx
import pygraphviz as pgv
from math import log

G = nx.read_graphml('ITC_2_012_idx8.graphml')

indices = set([idx for n, idx in G.nodes.data('index')])
radii = [log(idx)/log(max(indices)) for n, idx in G.nodes.data('index')]
shells = [[n for n, idx in G.nodes.data('index') if idx == x] for x in indices]
pos = nx.shell_layout(G, shells)

A = nx.nx_agraph.to_agraph(G)

A.graph_attr['splines'] = 'spline' # or 'polyline'
A.graph_attr['scale'] = '0.6'
A.graph_attr['esep'] = '0.5' # node-edge distance
A.node_attr['shape'] = 'circle'
A.node_attr['pin'] = 'true'
for k in A.nodes():
    n = A.get_node(k)
    n.attr['label'] = str(n.attr['index']) # add label 
    n.attr['pos'] = str(pos[k][0]*10)+','+str(pos[k][1]*10)+'!' # set pos string 
    
# print(A.to_string())

A.layout() # default 'neato' which respects the node attribute 'pos'
A # rich output in Jupyter Notebook/Lab using pygraphviz 1.9, Feb 2022

enter image description here

The edge-node crossings are gone.

However, this solution is not yet as I would like to have it:
I would prefer inbound and outbound edges are docked at the nodes on opposite sites (except root node).
yEd radial layout with edge routing does this or see my low-res self-made layout and routes.

Update: Enforce tailport

import networkx as nx
import pygraphviz as pgv
from math import atan2, log, pi

G = nx.read_graphml("ITC_2_012_idx8.graphml")
indices = set([int(idx) for n, idx in G.nodes.data('index')])
radii = [log(idx)/log(max(indices)) for n, idx in G.nodes.data('index')]
shells = [[n for n, idx in G.nodes.data('index') if idx == x] for x in indices]
pos = nx.shell_layout(G, shells)

A = nx.nx_agraph.to_agraph(G)

pos_factor = 12
A.graph_attr['scale'] = "0.5"
A.graph_attr['esep'] = "1"
A.graph_attr['splines'] = "spline"
A.node_attr['shape'] = "circle"
A.node_attr['pin'] = "true"
A.edge_attr['arrowhead']="vee"
for k in A.nodes():
    k.attr["label"] = str(k.attr["index"]) 
    k.attr["pos"] = str(pos[k][0]*pos_factor)+','+str(pos[k][1]*pos_factor)+"!" 

# Set 'tailport' based on quadrant of tail node 
for n1, n2 in A.edges():
    if n1 == A.nodes()[0]: # skip root edges
        continue
    e = A.get_edge(n1, n2)
    theta = atan2(pos[n1][1], pos[n1][0])/pi*180.
    
    if -22.5 <= theta < 22.5:
        e.attr["tailport"] = 'e'
    elif 22.5 <= theta < 67.5:
        e.attr["tailport"] = 'ne'
    elif 67.5 <= theta < 112.5:
        e.attr["tailport"] = 'n'
    elif 112.5 <= theta < 157.5:
        e.attr["tailport"] = 'nw'
    elif 157.5 <= theta <= 180. or -157.5 > theta > -180.:
        e.attr["tailport"] = 'w'
    elif -157.5 <= theta <= -112.5:
        e.attr["tailport"] = 'sw'
    elif -112.5 <= theta <= -67.5:
        e.attr["tailport"] = 's'
    elif -67.5 <= theta <= -22.5:
        e.attr["tailport"] = 'se'
    else:
        raise ValueError('Quadrant determination failed for node', n1,
                         'with polar angle', theta)
    
# Mark problematic edges
A.get_edge('10', '14').attr["color"] = "red"
A.get_edge('04', '06').attr["color"] = "blue"
A.get_edge('06', '18').attr["color"] = "orange"

A.layout() # default 'neato'
A

enter image description here

However, IMHO the visualisation does not become clearer (easy to grasp the connectivity) since some highly curved edges (e.g. red one) are introduced and there are parallel edge overlaps (e.g. blue and orange).

图形图:带有给定节点半径和非旋转边缘的径向布局

神仙妹妹 2025-02-19 19:59:38

您可以使用 split(“”)将单个空格字符分配。如果您有多个,则可能需要使用Regex和 \ s+。我还添加了一个列表理解,以将其转换为整数值,因为您的预期输出以这种方式格式化了。希望这有帮助!

dic = {'a': '12 34 12','b':'23 43 12','c':'21' }

for k in dic:
    # dic[k] = dic[k].split(" ") # if you're okay with strings

    # if you want conversion to int
    dic[k] = [int(i) for i in dic[k].split(" ")]

print(dic)
# >>> {'a': [12, 34, 12], 'b': [23, 43, 12], 'c': [21]}

You can use split(" ") which splits on a single whitespace character. If you have more than one you might want to use regex and \s+. I've also added a list comprehension to convert to integer values since your expected output formatted it that way. Hope this helps!

dic = {'a': '12 34 12','b':'23 43 12','c':'21' }

for k in dic:
    # dic[k] = dic[k].split(" ") # if you're okay with strings

    # if you want conversion to int
    dic[k] = [int(i) for i in dic[k].split(" ")]

print(dic)
# >>> {'a': [12, 34, 12], 'b': [23, 43, 12], 'c': [21]}

在Python中的字典列表中将每个键的值分开

神仙妹妹 2025-02-19 13:08:35

感谢SQ社区!
我们一直在使用 / lib /文件夹作为持续音量。
删除了该卷并重新部署,现在一切都像魅力一样工作

Thanks to SQ Community!
We've been using /lib/ folder as persistent volume.
Removed that volume and redeployed, now everything is working like a charm

Sonarqube 9.5中没有Terraform/Cloudformation?

神仙妹妹 2025-02-19 11:51:30

尝试以下操作:

function addNewItems() {
  var ss = SpreadsheetApp.getActive();
  var sh = ss.getSheetByName("New Items");
  let lastR = sh.getLastRow();
  var newInput1 = sh.getRange("A2:K" + lastR);
  var newInput2 = sh.getRange("N2:O" + lastR);
  var newInput3 = sh.getRange("Q2:R" + lastR);
  var newItems = sh.getRange(2, 1, lastR - 1, 17).getValues();
  var tsh = ss.getSheetByName("Price Book");
  tsIns = tsh.getLastRow();
  tsh.getRange(tsIns + 1, 1, lastR - 1, 17).setValues(newItems);
  newInput1.clearContent();
  newInput2.clearContent();
  newInput3.clearContent();
}

Try this:

function addNewItems() {
  var ss = SpreadsheetApp.getActive();
  var sh = ss.getSheetByName("New Items");
  let lastR = sh.getLastRow();
  var newInput1 = sh.getRange("A2:K" + lastR);
  var newInput2 = sh.getRange("N2:O" + lastR);
  var newInput3 = sh.getRange("Q2:R" + lastR);
  var newItems = sh.getRange(2, 1, lastR - 1, 17).getValues();
  var tsh = ss.getSheetByName("Price Book");
  tsIns = tsh.getLastRow();
  tsh.getRange(tsIns + 1, 1, lastR - 1, 17).setValues(newItems);
  newInput1.clearContent();
  newInput2.clearContent();
  newInput3.clearContent();
}

我有一个加油脚本可以将一系列单元格从一张纸复制到另一张单元格正确插入的数据,但也添加了两个额外的空白行

神仙妹妹 2025-02-19 10:10:07

尝试使用 Let 而不是 var

for (let i = 0; i < pages.length; i++) {

被屏蔽,并且 var 是范围范围的。

由于您正在调用 async 方法,因此使用 var 它将完成循环的,然后将最后一个值传递给回调。但是使用它将在回调中保留在块范围中分配的变量。

在这里> 的定义令在这里 var

try using let instead of var

for (let i = 0; i < pages.length; i++) {

let are block scoped and var are function scoped.

Since you are calling an async method, using var it will finish the for loop and pass the last value to the callback. But using let it will keep the variable assigned in the block scope in the callback.

Here is the definition for let, and here is for var.

使用axios。

神仙妹妹 2025-02-19 03:04:42

就我而言,我只使用 pdcsv.loc [index,name] = newVal来实现函数:

PDCsv.loc[0, 'Name'] = 'Anthony Dave'

In my case, I just use PDCsv.loc[index, name] = NewVal to realise the function:

PDCsv.loc[0, 'Name'] = 'Anthony Dave'

如何处理熊猫的withcopywarning

神仙妹妹 2025-02-19 00:18:01

如果您以以下方式更改初始代码,一切都会好的:

if ((cin >> name).get() && std::getline(cin, state))

Everything will be OK if you change your initial code in the following way:

if ((cin >> name).get() && std::getline(cin, state))

为什么STD :: getline()在格式提取后跳过输入?

神仙妹妹 2025-02-18 19:41:55

脚本返回值很重要。你对我看起来不错。我刚刚添加了几秒钟才等到应用程序启动。

如果您将 bash -x 与命令管道一起使用,则最好添加 shopt -s PipeFail ,因此当其中一个命令失败时,所有管道都会失败。

结帐我的脚本:

#!/bin/bash

sleep 5
curl http://localhost:3009 | grep Welcome

Script return value matters. Yours looks good to me. I just added couple of seconds to wait until application starts up.

In case you use bash -x together with pipeline of commands, you better add shopt -s pipefail so all pipeline fails when one of the commands fails.

Checkout my script:

#!/bin/bash

sleep 5
curl http://localhost:3009 | grep Welcome

AWS代码部署 - 指定位置的脚本:脚本/validate_service.sh失败了出口代码1

神仙妹妹 2025-02-18 17:34:31

我不确定您是否仍然需要一个答案,但是只有一个培训短语意味着您的模型并没有太大的匹配基础。对于您来说,作为人类的短语在语义上是完全不同的,但是对于模型而言,这些短语实际上是相似的短语,因为它只有一个例子,它不知道该短语的“重要”部分是从您的角度来看。
您可以在这里了解更多有关如何创建良好培训数据的信息/“ rel =“ nofollow noreferrer”> https://aws.amazon.com/blogs/machine-learning/best-practices-for-creating-mazon-azon-lex-interaction-models/

I'm not sure if you still need an answer on this, but having only one training phrase has meant your model doesn't have much to base the matching on. To you as a human the phrase is semantically completely different, but to the model those are actually similar phrases since it has only one example it doesn't know what are the "important" parts of the phrase from your perspective.
You can learn a bit more here about how to create good training data https://aws.amazon.com/blogs/machine-learning/best-practices-for-creating-amazon-lex-interaction-models/

LEX置信度得分不准确

神仙妹妹 2025-02-18 15:09:49

尝试使用 imapsmtp 库发送,阅读和删除电子邮件。 IMAPSMTP正在与SMTP和IMAP协议接口。
email.imapsmtp

Try using ImapSmtp library for sending, reading, and deleting emails. ImapSmtp is interfacing with SMTP and IMAP protocols.
Detailed code and documentation at Email.ImapSmtp

当机器人测试失败时,需要触发通过故障的电子邮件

神仙妹妹 2025-02-18 11:59:20

laravel 可以自动序列化模型,因此请确保您有关系,将其加载到模型中,并将其添加到您的 json 自动响应中。

class Page extends Model {
   public function category()
   {
       return $this->belongsTo(Category::class);
   }
}

使用 - &gt; load() lazy加载关系,如果必须在查询中使用类似的使用 - &gt;带(),这是急切的加载方法。

...

$page->save();
$page->load('category');

return response()->json([
    'data' => $page,
    'success' => 'File uploaded successfully.',
]);

这将添加类别作为一种关系,但这是最好的实践,而不是以更硬的编码方式添加名称。

也是填充关系ID作为属性或 fill()的下侧之一。如果您在关系函数上保存类别关系,则它规避 laravels 关系逻辑。它将以与上述相同的方式加载类别和工作。

$page->title = $request->title;
$page->slug = $request->slug;
$page->content = $request->contents;
$page->language = $request->language;

$page->category()->associate(Category::find($request->cat_id));

$page->save();

Laravel can automatically serialize models, so ensure you have a relationship, load it into the model and it will be added to your JSON response automatically.

class Page extends Model {
   public function category()
   {
       return $this->belongsTo(Category::class);
   }
}

Using ->load() to lazy load the relationship, if similar has to be done in a query use ->with() which is the eager loading approach.

...

$page->save();
$page->load('category');

return response()->json([
    'data' => $page,
    'success' => 'File uploaded successfully.',
]);

This will add the category as a relationship, but this is the best practice instead of adding the name in a more hard coded way.

Also one of the down sides of filling relationship ids as a property or with fill(). Is that it circumvented Laravels relationship logic, if you instead save the category relationship on the relationship function. It will have loaded the category and work, in the same manner as above.

$page->title = $request->title;
$page->slug = $request->slug;
$page->content = $request->contents;
$page->language = $request->language;

$page->category()->associate(Category::find($request->cat_id));

$page->save();

在Laravel发布后注册后,用模型编写类别名称

神仙妹妹 2025-02-18 11:09:41

我不认为您的解决方案很笨拙。只需添加一个简短的评论,例如“获取所有文档,如果管理员,否则获取授权阅读的所有文档”。

I don't think your solution is clunky. Just add a short comment like "fetch all documents if admin, otherwise fetch all documents authorized to read".

Firebase Collection查询更改如果用户具有admin自定义索赔

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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