for ... in 为您提供对象属性的键。您必须使用密钥访问该值
for (const key in rules)
{
console.log(key, rules[key]);
}
将扩展嵌套 swrconfig
配置。对于您的方案,这意味着如果您调用在第二个
,它将使用在此处定义的fetcher( swrconfig
内使用 custicfetch
)。
另外,您还可以在上定义fetcher
直接调用以在任何时候覆盖全局。
useSWR('my-key', customFetch)
我终于从Emacs-JP Slack获得了解决方案。我将重印它们,希望他们会为同样困扰的其他人提供帮助。
;; for company
(add-hook 'eglot-managed-mode-hook (lambda ()
(add-to-list 'company-backends
'(company-capf :with company-yasnippet))))
;; for corfu
(straight-use-package 'cape)
(defun my/eglot-capf ()
(setq-local completion-at-point-functions
(list (cape-super-capf
#'eglot-completion-at-point
(cape-company-to-capf #'company-yasnippet)))))
(add-hook 'eglot-managed-mode-hook #'my/eglot-capf)
我不能为开发人员讲话,但是我发现这种行为非常直观。
如果一种方法可在原始对象上使用并将其定为就地,则它不会返回任何内容,因为没有新信息 - 显然您已经对(现在突变)对象有一个引用,那么为什么还要再次返回它呢?
但是,如果方法或函数会创建一个新对象,那么它当然必须返回它。
因此 l.reverse()
什么都没有返回(因为现在列表已经相反,但是Identfier l
仍然指向该列表),但是 cretversed(l)
必须返回新生成的列表,因为 l
仍然指向旧的未修改列表。
您在项目目录中创建一个称为 dockerfile
的文本文件,然后将所有代码放入其中。
示例:
FROM ubuntu
RUN apt-get update && apt-get install -y <your-dependencys>
COPY . .
第二行安装图像上的软件包。
第三行将当前目录中的每个文件编写为图像。
这是一种看法,但是如果我不必这样做,我不喜欢藏匿;如果我在分支A上未完成的工作中间“正在进行的工作”),然后 git提取; git开关分支
。
无需说提取 - all
。无需推开分支A(这样做可能是个坏主意,因为它还没有烘烤)。无需拉动,因为 fetch
更新了所有内容。
但是,如果您已经拥有本地分支B,则切换到分支B后,您可能需要说 git Merge
才能更新本地分支。
根据他们的迁移指南的这一部分 此先前的修订版。。
pydantic确实允许通过现场验证器。创建一个时,您需要注意处理传入的数据并根据您的要求处理。在您的示例中,它应允许无
,标准 int
s以及代表十六进制字符串的任何 str
。因此,以下实施可以满足上述约束:
from typing import Optional
from pydantic import BaseModel, ValidationInfo, field_validator
class DataTemp(BaseModel):
aaa: int
# to allow the assignment of str along with int, even though the
# value will always be casted back to an int via the field validator,
# and set the default value to None to permit omitted key in V2
bbb: Optional[int | str] = None
@field_validator('bbb')
@classmethod
def validate_bbb(cls, v: Optional[int | str], info: ValidationInfo):
return int(v, 16) if isinstance(v, str) else v
用法:
>>> DataTemp(aaa=4, bbb=33)
DataTemp(aaa=4, bbb=33)
>>> DataTemp(aaa=4, bbb=None)
DataTemp(aaa=4, bbb=None)
>>> DataTemp(aaa=4) # bbb omitted, defaults to None as specified
DataTemp(aaa=4, bbb=None)
>>> DataTemp(aaa=4, bbb='0x333')
DataTemp(aaa=4, bbb=819)
>>> DataTemp(aaa=4, bbb='32')
DataTemp(aaa=4, bbb=50)
>>> DataTemp(aaa=4, bbb='asdf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pydantic/main.py", line 164, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for DataTemp
bbb
Value error, invalid literal for int() with base 16: 'asdf' [type=value_error, input_value='asdf', input_type=str]
For further information visit https://errors.pydantic.dev/2.5/v/value_error
我想您的内容是在file file.txt 中定义的:(我刚刚修改了 source4
的平均水平,以使数据 intactive> intactive> intactive> intactive
)
---------------------------------------------------------------------------
Counter Source | Counter Name | Unit | Min | Max | Average | Last
---------------+-----------------+-------+-------+-------+---------+-------
Source1 | GC1 | % | 3.00 | 22.00 | 3.01 | 3.00
Source2 | GC2 | % | 2.00 | 7.00 | 2.95 | 3.00
Source3 | GC3 | % | 2.00 | 12.00 | 3.00 | 3.00
Source4 | GC4 | % | 15.00 | 16.00 | 0.00 | 15.00
Source5 | GC5 | % | 39.00 | 44.00 | 41.32 | 43.00
-----------------------------------------------------------------------------
playbook:
- name: "tips1"
hosts: localhost
tasks:
- debug:
msg: "the source {{ _s }} is {{ 'active' if _av|float > 0.00 else 'inactive'}}"
loop: "{{ lookup('file', 'file.txt').splitlines() }}"
vars:
arr: "{{ item.split('|')|list}}"
_s: "{{ arr[0]|trim }}"
_av: "{{ arr[5]|trim|float }}"
when: '"%" in item'
结果:
skipping: [localhost] => (item=--------------------------------------------------------------------------- )
skipping: [localhost] => (item=Counter Source | Counter Name | Unit | Min | Max | Average | Last )
skipping: [localhost] => (item=---------------+-----------------+-------+-------+-------+---------+------- )
ok: [localhost] => (item=Source1 | GC1 | % | 3.00 | 22.00 | 3.01 | 3.00 ) => {
"msg": "the source Source1 is active"
}
ok: [localhost] => (item=Source2 | GC2 | % | 2.00 | 7.00 | 2.95 | 3.00 ) => {
"msg": "the source Source2 is active"
}
ok: [localhost] => (item=Source3 | GC3 | % | 2.00 | 12.00 | 3.00 | 3.00 ) => {
"msg": "the source Source3 is active"
}
ok: [localhost] => (item=Source4 | GC4 | % | 15.00 | 16.00 | 0.00 | 15.00 ) => {
"msg": "the source Source4 is inactive"
}
ok: [localhost] => (item=Source5 | GC5 | % | 39.00 | 44.00 | 41.32 | 43.00 ) => {
"msg": "the source Source5 is active"
}
skipping: [localhost] => (item=-----------------------------------------------------------------------------)
为了避免 ,您可以使用 @β.εηοιτ.βε提出的提示,
loop: "{{ lookup('file', 'file.txt').splitlines()[3:-1] }}"
看来您的问题有两个部分。您正在尝试找出WebDriver和用户配置文件路径。请允许我为您回答这两个问题。
在最新版本的Selenium中, executable_path
参数已弃用。现在需要包含可执行路径的服务对象。有两个选择。
服务对象
选项#1:使用可执行路径
附加此导入到您的代码上:
from selenium.webdriver.chrome.service import Service
然后,将服务对象包括在内:
driver = webdriver.Chrome(service=Service("C:\Program Files\Google\Chrome\Application\chrome.exe"))
选项#2:让Web Driver Manager处理它,
这非常适合当驱动程序过时时。无需重载驱动程序。
首先,转到终端中的项目目录。如果您使用的是Pycharm,则无需遍历目录,因为您已经在项目目录中了。
使用PIP安装Web驱动程序管理器:
pip install webdriver_manager
现在,无需输入可执行的路径:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.facebook.com")
选择用户配置文件
这很简单。首先,转到Chrome并输入 Chrome://版本/
进入URL地址栏。您将看到配置文件路径。它看起来像 c:\ users \ your -profile \ appdata \ local \ google \ chrome \ chrome \ user data \ default
。
然后,包括以下镀铬选项:
options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\Users\yourprofile\AppData\Local\Google\Chrome\User Data")
options.add_argument(r"--profile-directory=Default")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
@media screen and (max-width: 1200px) {
body {
font-size: 0.875rem;
}
}
不过,为了娱乐,这是一个完全响应的视口大小版式的工作示例。我在 html
选择器中明确设置字体,我使用 em
单元 body
中的字体以及所有段落和标题元素。我将所有内容都包装在另一个元素中,然后在该包装器上应用 vw
单位,以实现响应式的视口大小的版式。
html {
font: 62.5% sans-serif;
}
body {
background: #f2f2f2;
font: 1.6em/1.4 Roboto, sans-serif;
color: #333;
margin: 0;
padding: 0;
}
.wrapper-font-stretch {
font-size: 0.85vw;
}
h1 {
font: 5em Lato, sans-serif;
margin: 0.3em 0;
text-align: center;
}
h2 {
font: small-caps 4em Lato, sans-serif;
margin: 0.5em 0;
text-align: center;
}
.lorem {
font-size: 2.25em;
margin: 0 auto 2em;
max-width: 60ch;
text-align: justify;
}
.lorem:first-line {
font-size: 1.3em;
line-height: 1;
}
.lorem:first-letter {
font-family: "Dancing Script", sans-serif;
font-size: 2.9em;
font-weight: 700;
}
<div class="wrapper-font-stretch">
<h1>This is a Heading</h1>
<p class="lorem">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nostrum incidunt ducimus voluptas perspiciatis doloremque molestiae voluptate omnis, sequi dolor velit! Recusandae sunt iste tenetur ut nam aperiam? Minima repellat, mollitia ea odio veniam iusto
fugiat dicta deleniti neque fugit beatae voluptates quo perferendis eaque necessitatibus nihil. Molestias vel voluptatum eum rem quia! Numquam odio ad deserunt mollitia, est ipsum illo ex repellendus molestiae, aspernatur vitae porro saepe nulla,
voluptatum cum exercitationem quisquam? Pariatur accusamus et ratione, obcaecati nisi facilis vero maxime, minus, in sequi expedita ut illum. Cupiditate nesciunt, sint debitis et voluptates quae fugit ex illum. Suscipit, quas, delectus dolorem iure
maxime dicta quis quidem, exercitationem consequuntur vero doloremque veritatis nihil amet inventore animi eligendi fugiat libero obcaecati facere est ad modi dignissimos alias aperiam. At nesciunt, incidunt iusto laboriosam nemo ducimus ab rerum
voluptates, quam tenetur fugit vel sapiente impedit quia ut dolores. Amet vel aliquam quia harum voluptatem quidem consectetur, beatae ipsam, incidunt nemo doloribus maiores explicabo quibusdam ipsum dolor alias numquam obcaecati magnam eveniet? Tenetur
minima dolores iste incidunt vel? Consequuntur, in. Fugit consequuntur, voluptas magnam fuga necessitatibus veritatis quae ipsa eveniet doloribus facere, magni possimus architecto reprehenderit neque. Aperiam dignissimos ut temporibus quas odit repudiandae?</p>
<h2>this is a subheading</h2>
<p class="lorem">Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur nam beatae veniam adipisci sunt eos praesentium, consequatur, a accusantium corrupti, dolorem ea in laborum ducimus perspiciatis architecto nulla explicabo. Repudiandae dicta repellat
impedit quas. Fuga numquam accusantium perspiciatis iste magnam aliquam. Earum eius itaque magni magnam error. Adipisci, unde atque.</p>
</div>
您还可以在Codepen上查看此片段如果您想分叉并使用单位播放。
jsoncppconfig.cmake
定义属性 interface_include_directories
for targets jsoncpp_lib
和 JSONCPP_LIB_STATIC
。
您需要查询目标属性并手动设置:
get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${JSON_INC_PATH})
链接是通过:
target_link_libraries(${PROJECT_NAME} jsoncpp_lib)
源。
尝试以下操作:
cmake_minimum_required(VERSION 3.22.1)
project(ants)
# ".cpp" files in folder "src" into cmake variable "SOURCE"
file(GLOB SOURCE "src/*.cpp")
# Executable
add_executable(${PROJECT_NAME} ${SOURCE})
# Directory where cmake will look for include files
include_directories(include)
# Tells cmake to compile jsoncpp
add_subdirectory(external/jsoncpp)
get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${JSON_INC_PATH})
target_link_libraries(${PROJECT_NAME} jsoncpp_lib)
您可以使用这些代码行将其删除:
function stof_wp_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-blocks-style' );
}
add_action( 'wp_enqueue_scripts', 'stof_wp_remove_wp_block_library_css', 100 );
foo :: xs
的定义是必需的吗?
是的,因为正如Nathanoliver在注释中指出的那样,引用隐含地绑定到 foo :: XS
由基于范围的循环绑定。当您将引用对象绑定时,对象被odr使用。如果使用 std :: array
而不是原始数组,也会发生同样的情况。
如果我们避免基于范围?
好吧,如果您使用原始数组并使用不需要绑定引用的技术获取其大小,则可以避免提供定义:
for (int i = 0; i < sizeof(foo::xs)/sizeof(foo::xs[0]); i++) {
sum += foo::xs[i];
}
在这种情况下,在这种情况下, sizeof
是而不是odr-uses,因为它们是未化为的,而 foo :: xs
是 foo :: xs [i]
;后一种表达式是非类型的类型,并立即进行lvalue-to-rvalue转换,因此它不使用ODR使用 foo :: xs
。
您的模型似乎是:每个(唯一)元组
(O,U)
被分配一个强制性值d
。您可以通过在
program_outcome_unit_lookup
表:(program_outcome_fk,unit_fk)
)也可能是您的主要密钥来实现此模型。无论哪种方式,它都必须是唯一的(您当前没有执行此约束)。现在,每个
u
可以作为您想要的多数o
的成员/code> pero
“按要求”。到EG商店
u1
从您的更新图(o1-d2-u1
和o2-d1-u1
)),您将添加到> (o,d,u)
值((1,2,1),(2,1,1))
。根据要求,您还不能添加例如o2-d2-u1
,因为它会违反唯一的约束。您还应为
d
添加一个新表。如果不是每个d
,则允许每个o
(例如o2
分支不允许使用d1
),您还需要一个表(O,d)
,否则不需要。Your model seems to be: each (unique) tuple
(O, U)
is assigned a mandatory valueD
.You can implement this model by adding a column
D
to yourprogram_outcome_unit_lookup
table:(program_outcome_fk, unit_fk)
could be your primary key as well, but either way it has to be unique (you are currently not enforcing this constraint).Now each
U
can be member of as manyO
as you like, but "eachU
will be related to only oneD
perO
", as requested.To e.g. store
U1
from your updated graph (O1-D2-U1
andO2-D1-U1
), you would add into(O,D,U)
the values((1,2,1),(2,1,1))
. As requested, you cannot also add e.g.O2-D2-U1
, as it would violate the unique constraint.You should also add a new table for
D
. If not everyD
is allowed for everyO
(e.g. ifO2
branches are not allowed to useD1
), you will also need a table(O, D)
, otherwise it is not necessary.mysql-复杂的分层关系 - 多个m:n?