望喜

文章 评论 浏览 29

望喜 2025-02-20 23:49:53

我猜您可以通过使用createGraphics()来获得想要的东西。

var g = myButton.CreateGraphics();
g.DrawLine(Pens.Red, 0, 0, 20, 20);

Control表单替换Mybutton。

但是,这可能不是正确的方法。图纸将消失,例如,当表单被最小化,最大化,被其他形式覆盖等时,

建议的模式是使用paint事件 - 请参见 https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.paint?view=windowsdesktop-6

I am guessing you could obtain what you want by using CreateGraphics().

var g = myButton.CreateGraphics();
g.DrawLine(Pens.Red, 0, 0, 20, 20);

Replace myButton with the Control or Form you want to draw on.

This may turn out to not be the right approach though. The drawing will disappear e.g. when the form is minimized, maximized, gets covered by another form etc.

The recommended pattern is to use the Paint event - see https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.paint?view=windowsdesktop-6

从不同方法访问图形?

望喜 2025-02-20 23:40:12

使用用户按钮启动SQLPLU,您已经安装了Oracle。 SQLPlus应该在没有用户名和密码的情况下连接。连接后,您可以广告新用户。

sqlplus / as sysdba

Start sqlplus with the User-Account, you had install Oracle. sqlplus should connect without username and password. After you are connected, you can ad new users.

sqlplus / as sysdba

安装的Oracle 19c。在安装过程中,它没有要求使用用户名/密码。如何登录SQLPlus?

望喜 2025-02-20 18:19:57

这是使用 object-scan 的答案。

访问单个条目时,此答案实际上并没有比Vanilla JavaScript提供太大的好处。但是,同时与多个字段进行互动,此答案可能更具性能。

这是您可以与单个字段互动的方式

// const objectScan = require('object-scan');

const data = { code: 42, items: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }] };

const get = (haystack, needle) => objectScan([needle], {
  abort: true,
  rtn: 'value'
})(haystack);

const set = (haystack, needle, value) => objectScan([needle], {
  abort: true,
  rtn: 'bool',
  filterFn: ({ parent, property }) => {
    parent[property] = value;
    return true;
  }
})(haystack);

console.log(get(data, 'items[1].name'));
// => bar

console.log(set(data, 'items[1].name', 'foo2'));
// => true
console.log(data);
// => { code: 42, items: [ { id: 1, name: 'foo' }, { id: 2, name: 'foo2' } ] }
.as-console-wrapper {max-height: 100% !important; top: 0}
<script src="https://bundle.run/[email protected]"></script>

免责声明:我是 object-scan 的作者

这是您可以同时与多个字段互动的方式

// const objectScan = require('object-scan');

const data = { code: 42, items: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }] };

const get = (haystack, ...needles) => objectScan(needles, {
  joined: true,
  rtn: 'entry'
})(haystack);

const set = (haystack, actions) => objectScan(Object.keys(actions), {
  rtn: 'count',
  filterFn: ({ matchedBy, parent, property }) => {
    matchedBy.forEach((m) => {
      parent[property] = actions[m];
    })
    return true;
  }
})(haystack);

console.log(get(data, 'items[0].name', 'items[1].name'));
// => [ [ 'items[1].name', 'bar' ], [ 'items[0].name', 'foo' ] ]

console.log(set(data, {
  'items[0].name': 'foo1',
  'items[1].name': 'foo2'
}));
// => 2
console.log(data);
// => { code: 42, items: [ { id: 1, name: 'foo1' }, { id: 2, name: 'foo2' } ] }
.as-console-wrapper {max-height: 100% !important; top: 0}
<script src="https://bundle.run/[email protected]"></script>

免责声明:我是 object-scan 的作者


这是人们如何在通过ID搜索的深度嵌套对象中找到一个实体(如评论中所要求)

// const objectScan = require('object-scan');

const myData = { code: 42, items: [{ id: 1, name: 'aaa', items: [{ id: 3, name: 'ccc' }, { id: 4, name: 'ddd' }] }, { id: 2, name: 'bbb', items: [{ id: 5, name: 'eee' }, { id: 6, name: 'fff' }] }] };

const findItemById = (haystack, id) => objectScan(['**(^items$).id'], {
  abort: true,
  useArraySelector: false,
  rtn: 'parent',
  filterFn: ({ value }) => value === id
})(haystack);

console.log(findItemById(myData, 5));
// => { id: 5, name: 'eee' }
.as-console-wrapper {max-height: 100% !important; top: 0}
<script src="https://bundle.run/[email protected]"></script>

免责声明:我是 object-scan 的作者

Here is an answer using object-scan.

When accessing a single entry, this answer doesn't really provide much benefit over vanilla javascript. However interacting with multiple fields at the same time this answer can be more performant.

Here is how you could interact with a single field

// const objectScan = require('object-scan');

const data = { code: 42, items: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }] };

const get = (haystack, needle) => objectScan([needle], {
  abort: true,
  rtn: 'value'
})(haystack);

const set = (haystack, needle, value) => objectScan([needle], {
  abort: true,
  rtn: 'bool',
  filterFn: ({ parent, property }) => {
    parent[property] = value;
    return true;
  }
})(haystack);

console.log(get(data, 'items[1].name'));
// => bar

console.log(set(data, 'items[1].name', 'foo2'));
// => true
console.log(data);
// => { code: 42, items: [ { id: 1, name: 'foo' }, { id: 2, name: 'foo2' } ] }
.as-console-wrapper {max-height: 100% !important; top: 0}
<script src="https://bundle.run/[email protected]"></script>

Disclaimer: I'm the author of object-scan

and here is how you could interact with multiple fields at the same time

// const objectScan = require('object-scan');

const data = { code: 42, items: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }] };

const get = (haystack, ...needles) => objectScan(needles, {
  joined: true,
  rtn: 'entry'
})(haystack);

const set = (haystack, actions) => objectScan(Object.keys(actions), {
  rtn: 'count',
  filterFn: ({ matchedBy, parent, property }) => {
    matchedBy.forEach((m) => {
      parent[property] = actions[m];
    })
    return true;
  }
})(haystack);

console.log(get(data, 'items[0].name', 'items[1].name'));
// => [ [ 'items[1].name', 'bar' ], [ 'items[0].name', 'foo' ] ]

console.log(set(data, {
  'items[0].name': 'foo1',
  'items[1].name': 'foo2'
}));
// => 2
console.log(data);
// => { code: 42, items: [ { id: 1, name: 'foo1' }, { id: 2, name: 'foo2' } ] }
.as-console-wrapper {max-height: 100% !important; top: 0}
<script src="https://bundle.run/[email protected]"></script>

Disclaimer: I'm the author of object-scan


And here is how one could find an entity in a deeply nested object searching by id (as asked in comment)

// const objectScan = require('object-scan');

const myData = { code: 42, items: [{ id: 1, name: 'aaa', items: [{ id: 3, name: 'ccc' }, { id: 4, name: 'ddd' }] }, { id: 2, name: 'bbb', items: [{ id: 5, name: 'eee' }, { id: 6, name: 'fff' }] }] };

const findItemById = (haystack, id) => objectScan(['**(^items$).id'], {
  abort: true,
  useArraySelector: false,
  rtn: 'parent',
  filterFn: ({ value }) => value === id
})(haystack);

console.log(findItemById(myData, 5));
// => { id: 5, name: 'eee' }
.as-console-wrapper {max-height: 100% !important; top: 0}
<script src="https://bundle.run/[email protected]"></script>

Disclaimer: I'm the author of object-scan

如何访问和处理嵌套对象,数组或JSON?

望喜 2025-02-20 18:13:11

虽然我找不到实现这一目标的标准方法,但是有一种稍微骇人的方法对我有用:

复制node_modules目录允许该软件包充当独立模块。但是,有一个警告:node_modules目录在工作区中的每个软件包中包含一个符号链接。因此,当循环被复制到包装中时,然后遵循符号链接时开始。为了防止这种情况,我们首先必须删除包裹。因此,部署脚本看起来像这样:

rm ./node_modules/cloud-app
cp -rL ./node_modules ./cloud-app/node_modules
# deploy cloud-app here

我在提出上述问题时想到了这一点,但仍然很高兴知道是否有任何规范,支持的方法可以做到这一点。

While I did not find a standard way to achieve this, there is a slightly hacky way that worked for me:

Copying the node_modules directory allows the package to act as a stand-alone module. However, there is one caveat: The node_modules directory contains a symlink for each package in the workspace. Thus, a loop begins when it is copied into a package and when symlinks are followed. To prevent this, we first have to delete our package. Therefore, a deploy script could look something like this:

rm ./node_modules/cloud-app
cp -rL ./node_modules ./cloud-app/node_modules
# deploy cloud-app here

I thought of this while formulating the above question but would still be delighted to know whether there is any canonical, supported way to do this.

运行“ NPM安装”好像包装不在工作区

望喜 2025-02-20 04:21:37

当将空依赖关系数组作为第二个参数传递给使用效果时,useffect回调中的代码只能在MOUNT上运行。此刻,数组仍然空。

当您还将数组添加到这样的第一个使用效果的依赖项数组中时,它是否有效?

useEffect(() => {
    return () => {
      console.log(array); // logs "[]"
    // TODO: Send to a post request to BE
    }
  }, [array])

顺便说一句,我认为您也可以将两者结合在一起:

useEffect(() => {
    console.log('array: ', array); // logs "(3) [{…}, {…}, {…}]" 

    return () => {
      console.log(array); // logs "[]"
    // TODO: Send to a post request to BE
    }
  }, [array])

When passing an empty dependency array as second argument to useEffect, the code inside the useEffect callback will only be run on mount. At this moment, array is still empty.

Does it work when you also add the array to the dependency array of the first useEffect like this?

useEffect(() => {
    return () => {
      console.log(array); // logs "[]"
    // TODO: Send to a post request to BE
    }
  }, [array])

BTW, I think you can also combine the two like this:

useEffect(() => {
    console.log('array: ', array); // logs "(3) [{…}, {…}, {…}]" 

    return () => {
      console.log(array); // logs "[]"
    // TODO: Send to a post request to BE
    }
  }, [array])

React componentWillunMount挂钩(使用效果)与React Hook(Usestate)阵列空无一人吗?

望喜 2025-02-20 03:24:08

例如,从IDE运行时,该代码在不运行maven-build jar时是否有效?如果是这样,请确保文件实际上包含在JAR中。资源文件夹应包含在&lt;构建中的POM文件中。

Does the code work when not running the Maven-build jar, for example when running from your IDE? If so, make sure the file is actually included in the jar. The resources folder should be included in the pom file, in <build><resources>.

如何从资源文件夹加载文件?

望喜 2025-02-19 19:26:18

摘自 linebreakStrategy propertyuilabel上,有助于控制此行为:

标签具有属性字符串值时,系统忽略textColorfonttextAlignmentline> line breactmodelineBreakStrategy属性。设置nsForegroundColoratTributeNamensfontattributenameAlignmentline breactmodeline> linebreakstrategy而是归因的字符串。

如果您想使用特定的线路断路策略,例如 (“文本系统使用与标准UI标签相同的线突破策略的配置。 ”),您需要通过段落样式将属性应用于属性字符串:

let style = NSMutableParagraphStyle()
style.lineBreakStrategy = .standard

let text = NSMutableAttributedString(
    string: "long title with an asterisk at the end *",
    attributes: [.paragraphStyle: style]
)

titleLabel.attributedText = text

根据您的文本,它 May 也有助于设置 允许defaultTigheningForruncation 在段落样式上,因为这可能允许文本系统在字符串的最后一行中拧紧单词之间的空间,以使所有内容都适合。 (我说 May ,因为此属性专门控制截断,但是文本系统也可以考虑包装。)

From the documentation of the lineBreakStrategy property on UILabel, which helps control this behavior:

When the label has an attributed string value, the system ignores the textColor, font, textAlignment, lineBreakMode, and lineBreakStrategy properties. Set the NSForegroundColorAttributeName, NSFontAttributeName, alignment, lineBreakMode, and lineBreakStrategy properties in the attributed string instead.

If you want to use a specific line break strategy, like .standard ("The text system uses the same configuration of line-break strategies that it uses for standard UI labels. "), you will need to apply the attribute to the attributed string via a paragraph style:

let style = NSMutableParagraphStyle()
style.lineBreakStrategy = .standard

let text = NSMutableAttributedString(
    string: "long title with an asterisk at the end *",
    attributes: [.paragraphStyle: style]
)

titleLabel.attributedText = text

Depending on your text, it may also help to set allowsDefaultTighteningForTruncation on the paragraph style because that may allow the text system to tighten the space between words on the last line of the string to get everything to fit. (I say may because this property controls truncation specifically, but it's possible that the text system can take it into account for wrapping as well.)

启用孤儿词功能NSMutableAbeatTributterString

望喜 2025-02-19 13:08:21

考虑一下问题。您需要i立方体与j平方相同吗?

我们知道对(0,0)(1,1)(4,8)(9) ,27)满足此条件。

0, 1 ,49都有什么共同点?

它们0123平方。

那么0, 1 ,827都有什么共同点?

它们是相同的数字。

一旦意识到模式,答案就可以在很短的时间内计算出来。

Think about the problem. You need i cubed to be the same as j squared?

We know that pairs like (0, 0), (1, 1), (4, 8), and (9, 27) satisfy this condition.

What do 0, 1, 4, and 9 all have in common?

They're 0, 1, 2, and 3 squared.

What then do 0, 1, 8, and 27 all have in common?

They're the same numbers cubed.

Once you realize the pattern, the answer can be calculated in extremely short time.

如何有效地找到一个数字对,其中一个平方等于另一个的立方体?

望喜 2025-02-19 06:05:00

您的数据已编码UTF16。您可以读取指定编码的内容:

pd.read_csv(dwn_url, encoding='utf16')

结果:

           email first_name     last_name
0            NaN        NaN           NaN
1  [email protected]       Luca         Rossi
2  [email protected]     Daniel       Bianchi
3  [email protected]    Gabriel  Domeneghetti
4  [email protected]  Christian          Bona
5  [email protected]     Simone      Marsango

< /code> 可以直接从URL读取,无需请求Stringio。)

You data is UTF16 encoded. You can read it specifying the encoding:

pd.read_csv(dwn_url, encoding='utf16')

Result:

           email first_name     last_name
0            NaN        NaN           NaN
1  [email protected]       Luca         Rossi
2  [email protected]     Daniel       Bianchi
3  [email protected]    Gabriel  Domeneghetti
4  [email protected]  Christian          Bona
5  [email protected]     Simone      Marsango

(read_csv can directly read from a url, no need for requests and StringIO.)

从Google Drive或使用Python Pandas读取CSV文件

望喜 2025-02-19 05:38:27

通常,dataframe.applymap非常慢,因此您应该避免使用它。我会将两个列叠放在一个列中,然后选择具有长度4的ID:

import pandas as pd

df = pd.DataFrame({'old_id':['111', '2222','3333', '4444'], 'new_id':['5555','6666','777','8888']})

ids = df.stack()
bad_ids = ids[ids.str.len() != 4]

输出:

>>> bad_ids

0  old_id    111
2  new_id    777
dtype: object

此方法的优点是,现在您拥有不良ID的位置,以后可能有用。如果您不需要它,则只能使用ids = df.stack()。reset_index()

In general, DataFrame.applymap is pretty slow, so you should avoid it. I would stack both columns in a single one, and select the ids with length 4:

import pandas as pd

df = pd.DataFrame({'old_id':['111', '2222','3333', '4444'], 'new_id':['5555','6666','777','8888']})

ids = df.stack()
bad_ids = ids[ids.str.len() != 4]

Output:

>>> bad_ids

0  old_id    111
2  new_id    777
dtype: object

The advantage of this approach is that now you have the location of the bad IDs which might be useful later. If you don't need it you can just use ids = df.stack().reset_index().

创建一个新的数据框

望喜 2025-02-18 18:57:28

Regex

通过REGEX捕获组很容易实现。您的模式将为“ paramfield \\(paramname =(。+),paramvalue =(。+)\\)',然后您只需匹配并获得group> group(1)组(2)

提取它后,只需在;或类似的情况下使用String Joiner创建字符串即可。

可以看起来像这样:

Pattern pattern = Pattern.compile("ParamField\\(paramName=(.+), paramValue=(.+)\\)");

StringJoiner sj = new StringJoiner(";");
for (String paramField : paramFields) {
  Matcher matcher = pattern.matcher(paramField);
  if (!matcher.find()) {
    throw new IllegalArgumentException("Bad input format");
  }

  String name = matcher.group(1);
  String value = matcher.group(2);

  sj.add(name + "-" + value);
}

String result = sj.toString();

使用OOP,

理想情况下,您可以使用一些OOP,并使用该字符串上的出厂方法创建一个不错的记录Paramfield,然后使用其Getters。这样,如果您需要做更多的事情,就可以更容易继续使用数据。

record ParamField(String name, String value) {
  private static Pattern pattern = Pattern.compile(
    "ParamField\\(paramName=(.+), paramValue=(.+)\\)");

  static ParamField of(String line) {
    Matcher matcher = pattern.matcher(line);
    if (!matcher.find()) {
      throw new IllegalArgumentException("Bad input format");
    }
    return new ParamField(matcher.group(1), matcher.group(2));
  }
}

使用类似的用法

List<ParamField> paramFields = lines.stream()
  .map(ParamField::of)
  .toList();

,然后使用该数据。例如,构建字符串:

String result = paramFields.stream()
  .map(paramField -> paramField.name() + "-" + paramField.value())
  .collect(Collectors.joining(";"));

枚举,

如果您需要使用数据进行更多复杂的事情,我建议您进一步迈进一步,还将 value 放入枚举中,例如

enum ParamValue {
  ADMITTED("Admitted"),
  DISCARDED("Discarded");

  // field, constructor, getter, of-method
}

:不必再与RAW字符串一起工作,但是请获得所有类型安全的Java可以为您提供的。

Regex

This is fairly easy to achieve with regex capturing groups. Your pattern will be "ParamField\\(paramName=(.+), paramValue=(.+)\\)" and then you simply match and get group(1) and group(2).

Once you extracted that, simply create the string with a StringJoiner on ; or similar.

Could look something like this:

Pattern pattern = Pattern.compile("ParamField\\(paramName=(.+), paramValue=(.+)\\)");

StringJoiner sj = new StringJoiner(";");
for (String paramField : paramFields) {
  Matcher matcher = pattern.matcher(paramField);
  if (!matcher.find()) {
    throw new IllegalArgumentException("Bad input format");
  }

  String name = matcher.group(1);
  String value = matcher.group(2);

  sj.add(name + "-" + value);
}

String result = sj.toString();

With OOP

Ideally you would employ some OOP though and create a nice record ParamField with a factory method on that string and then use its getters. That way its easier to keep working with the data, in case you need to do more with it.

record ParamField(String name, String value) {
  private static Pattern pattern = Pattern.compile(
    "ParamField\\(paramName=(.+), paramValue=(.+)\\)");

  static ParamField of(String line) {
    Matcher matcher = pattern.matcher(line);
    if (!matcher.find()) {
      throw new IllegalArgumentException("Bad input format");
    }
    return new ParamField(matcher.group(1), matcher.group(2));
  }
}

with a usage like

List<ParamField> paramFields = lines.stream()
  .map(ParamField::of)
  .toList();

and then work with that data. For example build your string:

String result = paramFields.stream()
  .map(paramField -> paramField.name() + "-" + paramField.value())
  .collect(Collectors.joining(";"));

Enum

If you need to do more complex stuff with the data, I would suggest you go one step further and also put the value into an enum, such as:

enum ParamValue {
  ADMITTED("Admitted"),
  DISCARDED("Discarded");

  // field, constructor, getter, of-method
}

so that you do not have to work with raw strings anymore but get all the type-safety Java can provide to you.

我如何使用Java8或Regex通过Mutliple定界器解析字符串

望喜 2025-02-18 08:06:58

我得到了解决方案的人:

通常,如果您遇到了类似的错误,则可能在建立连接后没有睡觉。

尝试添加:time.sleep(5)呼叫ws.run_forever()

这允许在向其发送任何请求之前成功连接Websocket连接。

Guys I have got the solution:

In general, if you have encountered a similar error like me, it's possible that you didn't sleep the program after establishing the connection.

Try to add: time.sleep(5) after calling ws.run_forever()

This allows the websocket connection to be successfully connected before sending any request to it.

无法使用websocket:websocket._exceptions.websocketConnectionClosedCeption:套接字已关闭

望喜 2025-02-18 03:30:41

React路由器V6中的API已从V5变化。

请参阅下面的接受答案:
” ')“在V6 React路由器中测试页面时

The API in React Router v6 has changed from that of v5.

See the accepted answer in the following:
"Cannot read properties of undefined (reading 'pathname')" when testing pages in the v6 React Router

React路由器:无法读取属性&#x27; pathname&#x27;不确定的

望喜 2025-02-17 22:30:59

当您使用res = requests.get(list_of_pages)时,您将HTTP连接到list_of_pages。但是requests.get将URL字符串作为参数(例如http:// localhost:8080/static/image 01.jpg),查看什么list_of_pages是 - 它已经是一个已经是一个打开文件。不是字符串。您必须使用请求库,也不是文件IO API,而不是两者兼而有之。

如果您已经打开了文件,则无需完全创建HTTP请求。您不需要此request.get()。解析list_of_pages像普通的本地文件一样。

或者,如果您想以另一种方式走,请不要在list_of_arguments中打开此文本文件,将其作为带有该文件的URL的字符串。

When you use res = requests.get(list_of_pages) you're creating HTTP connection to list_of_pages. But requests.get takes URL string as a parameter (e.g. http://localhost:8080/static/image01.jpg), and look what list_of_pages is - it's an already opened file. Not a string. You have to either use requests library, or file IO API, not both.

If you have an already opened file, you don't need to create HTTP request at all. You don't need this request.get(). Parse list_of_pages like a normal, local file.

Or, if you would like to go the other way, don't open this text file in list_of_arguments, make it a string with URL of that file.

在网页中搜索一个单词,然后保存到python中的txt

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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