目前尚不清楚显示的代码如何导致该错误。
这种代码应为“表驱动”,从而导致较少的代码和更多的可扩展性。
这样的事情:
from glob import glob
from os.path import join, isfile
from shutil import move
from pathlib import Path
BASE = 'C:\\Users\\CLEMENT.LAPORTE'
DEFAULT = 'Other'
CONTROL = {('gif', 'jfif', 'jpg', 'jpeg', 'png'): 'Pictures\\Pictures',
('mp4', 'mkv', 'avi'): 'Videos\\Videos',
('mp3', 'wav', 'm4a'): 'Music\\Songs',
('exe',): 'App',
('txt', 'docx', 'pptx', 'pdf'): 'Work',
('py', 'c', 'cpp', 'java', 'js', 'html', 'css'): 'Code'}
def moveFiles(path):
for file in glob(join(path, '*.*'):
suffix = Path(file).suffix[1:]
for k, v in CONTROL.items():
if suffix in k:
p = v
break
else:
p = DEFAULT
try:
move(file, join(BASE, p))
print(f"Moved: {file} -> {p}")
except Exception as e:
print(f'Failed to move {file} -> {p} due to {e}')
path = input("Enter the path you want to sort: ")
moveFiles(path)
好的,我编写的代码要简单得多。我将尝试解释:
html:
<p id="txtInput">Speak this text</p> // change to paragraph element but keep the same ID
<button id='btnSpeak'>Speak!</button>
javascript:
var txtInput = document.querySelector('#txtInput');
var btnSpeak = document.querySelector('#btnSpeak');
var synth = window.speechSynthesis;
var voices = [];
PopulateVoices();
if(speechSynthesis !== undefined){
speechSynthesis.onvoiceschanged = PopulateVoices;
}
btnSpeak.addEventListener('click', ()=> {
var toSpeak = new SpeechSynthesisUtterance(txtInput.textContent);
toSpeak.voice = voices[7]; // Spanish
synth.speak(toSpeak);
});
function PopulateVoices(){
voices = synth.getVoices();
voices.forEach((item, index) => console.log(item.name, index));
}
要注意的主要内容,我将输入更改为段落元素,但将其分配给了相同的ID(这意味着ID和元素的名称不再真正有意义 txtinput < /代码>段落等,但这是学术的)。 DOM中只有一个ID应该存在,因此请确保您删除另一个元素,如果它是重复的,则可以更改元素的ID并像
<p id="foo">Text</a>
var elementID = document.querySelector('#foo');
以前的功能中更新 JS选择器一样更新JS选择器。输入文本的值使用:
var toSpeak = new SpeechSynthesisUtterance(txtInput.value);
由于段落元素没有值属性,因此我们将其更改为:
var toSpeak = new SpeechSynthesisUtterance(txtInput.textContent);
它将返回内部文本内容。
我从API中获得了一系列的声音,为了调试目的,我是控制所有语音名称和索引:
voices.forEach((item, index) => console.log(item.name, index));
例如:它返回:
Microsoft David - English (United States) 0
Microsoft Mark - English (United States) 1
Microsoft Zira - English (United States) 2
...
这显示了我的每个声音,因为现在我已经设置了索引7(这是GoogleEspañol)作为预设的声音。您将必须更新所需的声音索引:
toSpeak.voice = voices[7]; // Spanish
我希望这是有道理的,现在代码将ES5样式语法(及较旧的)与更现代的版本混合在一起,这不是我的喜好,但这应该按预期工作。
还有一个 jsfiddle 您可以尝试实验
您需要将逻辑移到应用外。当它说时,请确保将组件包裹在A&lt; Provider&gt;
中,这意味着您使用的 useselector
In的组件需要在&lt下;提供者&gt;
在这种情况下意味着app.js。
因此,app.js仅包含
export default function App() {
return (
<Provider store={store}>
<NewComponent .../>
</Provider>
);
}
,newcomponent.js应包含其余逻辑。
按课堂选择效果很好:
soup.find('div',attrs={'class':'List-results-items'})
或
soup.find_all('div',attrs={'class':'List-results-items'})
示例
from bs4 import BeautifulSoup
soup='''
<div _ngcontent-ijy-c117 class="List-results-items">some text</div>'''
soup=BeautifulSoup(soup)
soup.find('div',attrs={'class':'List-results-items'})
输出
<div _ngcontent-ijy-c117="" class="List-results-items">some text</div>
以防万一您必须迭代 Resultset
以获取每篇文章。示例 - &gt;
from bs4 import BeautifulSoup
soup='''
<div _ngcontent-ijy-c117 class="List-results-items">
<a>Article One<a/>
<a>Article Two<a/>
<a>Article Three<a/>
</div>'''
soup=BeautifulSoup(soup)
for e in soup.find('div',attrs={'class':'List-results-items'}).find_all('a'):
print(e.text)
更改代码,您需要添加项目的 countarray
(如果项目为数组)或项目本身(如果不是数组)总和。
const array = [1, [2, [3,4]], [5,6], 7];
var countArray = function(array) {
let sum = 0
for (let i = 0; i < array.length; i++) {
if (Array.isArray(array[i])) {
sum = sum + countArray(array[i])
} else {
sum = sum + array[i]
}
}
return sum
}
console.log(countArray(array));
async
是“病毒”,因为如果您调用 async
方法,您的调用代码也必须是 async
,并且必须等待
您正在调用的方法的结果。因此,一个 async
使用倾向于强制许多其他因代码也为 async
,这又可能导致其他代码为 async
,它可以侵扰整个代码基础。
它在表单的按钮点击事件中起作用,因为Visual Studio足够聪明,可以看到事件处理程序方法为 async
,并在提出事件时适当地将其称为。
您需要声明函数历史记录()和列表,
last_calculation = []
def history():
global last_calculation
if last_calculation == []:
print("No past calculations to show")
else:
for i in last_calculation:
print(*i) #for single line
然后在if循环中添加以下代码到操作的末尾,
last_calculation.append(result)
然后触发histort()函数,使用“继续”以在呼叫历史记录之后进行操作()
if choice=='?':
history()
continue
我正在使用的最后一个工作。此外,似乎更简单,更完整
https://mongoplayground.net/pp/p/ku2clkxcpm0
db.collection.aggregate([
{
$match: {
userId: {
$in: [
"6288ceea279219e36338b5bc"
]
}
}
},
{
$sort: {
_id: -1
}
},
{
$group: {
_id: {
userId: "$userId"
},
docs: {
$first: "$ROOT"
}
}
},
{
$project: {
_id: 0
}
},
{
$replaceRoot: {
newRoot: "$docs"
}
}
])
当我最初编写此情况时,我不会添加参数,例如:
@allure.story("测试test_b")
def test_b(self):
"""
description of test_b
"""
logging.info("我是test_b的logging")
assert 1 in [0, 1]
运行它。
Allure Report从“ Allure-results”文件夹中读取测试结果数据,其中没有参数测试结果的test_b被保留,而未被新测试替换。这就是test_b在报告中的位置。
我可以删除两个“诱人的重学”和“ Allure-Report”文件夹来清洁测试结果数据。这样,将不会显示原始的“ test_b”。
要提取 entityID
,请:
print(resp2['entityId'])
提取 dentedname
,做:
print(resp2['properties']['detectedName'])
对于 sql-server
,请尝试以下操作:
-- mockup data
declare @Raw table (
id nvarchar(max),
group_id nvarchar(max),
user_id nvarchar(max)
)
insert into @Raw values ('p001', 'aaa', 'ava001'), ('p002', 'aaa', 'ava001'), ('p003', 'bbb', 'ava001'), ('p004', 'bbb', 'ava001');
-- check this query
with A as (
select id, ROW_NUMBER() over(partition by group_id, user_id order by id) as RN
from @Raw)
delete from @Raw where id in (select id from A where A.RN > 1)
-- verify table
select * from @Raw
我在gnu手册(扩展 - ass)中发现“ h” in'%h1'表示'the''sud'添加8个字节到一个倒数记忆参考'。
该模板修饰符是x86仅有的。它不适用于手臂。
不幸的是,不幸的是,手臂的模板修饰符未记录在GCC手册中(虽然它们适用于aarch64 ),但它们是在 armclang手册和GCC符合这些定义,据我所知。因此, h
模板修饰符的正确含义是:
操作数必须使用R约束,并且必须是64位整数或浮点类型。该操作数被打印为最高的寄存器,持有该值的一半。
现在这是有道理的。操作数1到Inline ASM是 oldVal
,该是无符号的长长
,64位,因此编译器将为其分配两个连续的32位通用寄存器。假设它们是 r4
和 r5
,如此编译的输出。然后,%1
将展开 R4
,%H1
将扩展到 R5
,这正是<代码> ldrexd 指令需求。同样,%4,%h4
扩展到 r2,r3
和%5,%h5
扩展到 fp,ip ,替代名称
r11,r12 。
Frant的答案解释了应该做什么比较交换。 (拼写 cmpxchg
可能来自X86比较交换指令的助记符。)如果您现在阅读了代码,则应该看到它确实可以做到这一点。 teq; teqeq;
ldrexd 和 strexd
之间的bne 如果
,如果独家商店失败,则会导致重试,如果有中间访问旧
和*ptr
不平等,则将中止商店。和 teq;
strexd
之后的bne *ptr
(通过另一个核心,中断处理程序, ETC)。这就是确保原子性的方式。
您正在尝试在这里做两件事。
- 找到每个卖家的总销售额。
- 对每个卖家的总销售额进行排序。
在我的排序功能内部,您可以看到我正在卖方过滤所有销售。
一旦我只有一个卖家的销售,我就会使用“简化方法”将其销售量汇总到易于使用的数字中。
然后,我将以前的卖家数量与当前卖方数量进行比较,以使用排序方法重新排序它们。
我鼓励您阅读所使用方法的文档,以便您了解每个步骤正在发生的事情。
const sellers = [{
id: 1,
name: 'juan',
age: 23
}, {
id: 2,
name: 'adrian',
age: 32
}, {
id: 3,
name: 'apolo',
age: 45
}];
const sales = [{
equipo: 'frances',
sellerId: 2,
quantity: 234
}, {
equipo: 'italiano',
sellerId: 3,
quantity: 24
}, {
equipo: 'polaco',
sellerId: 1,
quantity: 534
}, {
equipo: 'frances',
sellerId: 2,
quantity: 1234
}, {
equipo: 'frances',
sellerId: 3,
quantity: 2342
}];
const expected = [{
id: 3,
name: 'apolo',
age: 45
}, {
id: 2,
name: 'adrian',
age: 32
}, {
id: 1,
name: 'juan',
age: 23
}]
const result = sellers.sort((a, b) => {
totalA = sales.filter(sale => sale.sellerId === a.id).reduce((acc, val) => acc + val.quantity, 0)
totalB = sales.filter(sale => sale.sellerId === b.id).reduce((acc, val) => acc + val.quantity, 0)
return totalB - totalA
})
// Check we get what we expect
console.log(JSON.stringify(expected) === JSON.stringify(result))
您要确保使用分配操作员而不是比较操作员。
尝试
document.getElementById('res')。值= rab;
而不是。You want to make sure you're using the assignment operator, instead of the comparison operator.
Try
document.getElementById('res').value = rab;
instead.如何使用JavaScript使用在文本框上进行计算器进行输入值,并使用按钮执行和减去添加和减去