如果要在查询上使用这些参数,
您应该使用Encodeuricomponent(),该eNCODEROMOMPONTINT()可以逃脱字符串,以便在查询中用作值。
const query = "attr1=" + value1 +
"&attr2=" + encodeURIComponent("va & lu&e2") +
"&attr3=" + value3
这将导致以下字符串:
"attr1=value1&attr2=va%20%26%20lu%26e2&attr3=value3"
因此每个'&'被编码为“%26”
以拆分它,您现在可以依靠'&'符号:
const splitArray = query.split('&')
虽然,我将对每个查询参数值使用Encodeuricomponent()。除非我确切地知道我使用哪个值,并且不需要逃脱。
添加 row_axis = 0
, col_axis = 1
, channel_axis = 2
to apply_affine_transform()
的参数。
您的图像的内存布局是“频道last”,但该功能认为它是“频道优先”。它(错误地)认为将图像列出为 [C,H,W]
,而不是 [H,W,C]
。
问题在于,您试图将字典列表插入数据库中,而不是单独插入每个字典,然后使用更新语句插入以再次将它们放在一起。以下代码现在应该适合您。它使用与原始代码相同的结构,但一次插入每个词典,而不是一次尝试完成所有字典。
# Import required modules
import requests
import json
from bs4 import BeautifulSoup
# Get the data
url = 'https://opensky-network.org//api/flights/departure?airport=EDDF&begin=1517227200&end=1517230800'
content = requests.get(url).content
dataset = json.loads(content)
# Create connection
conn = sqlite3.connect("Flights")
# Insert the data
try:
cursor = conn.cursor()
cursor.execute('''create table flights(icao24 VARCHAR(50), firstSeen VARCHAR(50), estDepartureAirport VARCHAR(50), lastSeen VARCHAR(50), estArrivalAirport VARCHAR(50), callsign VARCHAR(50), estDepartureAirportHorizDistance VARCHAR(50), estDepartureAirportVertDistance VARCHAR(50), estArrivalAirportHorizDistance VARCHAR(50), estArrivalAirportVertDistance VARCHAR(50), departureAirportCandidatesCount VARCHAR(50), arrivalAirportCandidatesCount VARCHAR(50))''')
cursor.executemany('''insert into flights(icao24, firstSeen, estDepartureAirport, lastSeen, estArrivalAirport, callsign, estDepartureAirportHorizDistance, estDepartureAirportVertDistance, estArrivalAirportHorizDistance, estArrivalAirportVertDistance,
departureAirportCandidatesCount, arrivalAirportCandidatesCount) values (?,?,?,?,?,?,?,?,?,?,?,?)''', (dataset,))
except Exception as E:
print('Error:', E)
else:
conn.commit()
print('Data inserted')
# Update the table to include the new information
try:
cursor = conn.cursor()
cursor.execute('''update flights set estDepartureAirport = ?, estDepartureAirportHorizDistance = ?, estDepartureAirportVertDistance = ?, estArrivalAirport = ?, estArrivalAirportHorizDistance = ?, estArrivalAirportVertDistance = ?, departureAirportCandidatesCount = ?, arrivalAirportCandidatesCount = ? where ICAO24 = ?''', (dataset.pop(0).get('estDepartureAirport'), dataset.pop(0).get('estDepartureAirportHorizDistance'), dataset.pop(0).get('estDepartureAirportVertDistance'), dataset.pop(0).get('estArrivalAirport'), dataset.pop(0).get('estArrivalAirportHorizDistance'), dataset.pop(0).get('estArrivalAirportVertDistance'), dataset.pop(0).get('departureAirportCandidatesCount'), dataset.pop(0).get('arrivalAirportCandidatesCount'), dataset.pop(0).get('ICAO24')))
except Exception as E:
print('Error:', E)
else:
conn.commit()
print('Data updated')
只需从 scrollview
删除 list
- 它本身就是可滚动的。
struct ContentView: View {
var body: some View {
List(notes){ note in
NoteView(note: note)
.padding(.bottom)
}
}
}
*问题的原因是该列表希望将父母的规模扩大,但是ScrollView没有自己的尺寸,并且期望需要滚动的大小,结果很明显 - 骑自行车冲突 - 不会崩溃/挂在骑自行车Swiftui断开布局 - 输出为空。
您在参数名称中有一个错别字: remote_bind_adress->远程_BIND_ADDRESS
。
将这2行更改为:
@app.route(“/”)
@route(“/”)
quotesview.register(app)
到
QuotesView.register(app, route_base='/')
尝试使用 ts-node-esm index.ts
启动项目
实际上使用的代码是:
const onViewableItemsChanged = useRef(({ viewableItems }) => {
setCurrentPageIndex(viewableItems[0].index ?? 0);
}).current;
这应该使这种方法的意图更加清晰。回电传递给 useref
仅在组件安装时一次调用一次,并且返回的对象跨安装座稳定。但是,使用此代码,用 .current
立即提取对象内部的值。本质上,这是为此组件的给定安装座创建稳定实例变量。
与例如:
const onViewableItemsChanged = ({ viewableItems }) => {
setCurrentPageIndex(viewableItems[0].index ?? 0);
};
这与使用 useref
的方法非常相似,只是每次组件重新租赁时都会重新创建该函数。 没有陈旧的封闭来担心这里该函数为 setCurrentPageIndex
, setCurrentPageIndex
在整个渲染中都是稳定的。
重新创建功能是否仅与使用该函数的儿童组件有关。当您将新功能作为支撑传递给儿童组件时,设计经过精心设计的子组件将检测到这种变化,删除使用 old old 函数的任何功能,然后使用新功能重新启动功能。例如,如果子组件具有:
const Child = ({ fn }) => (
<button onClick={fn}>click</button>
);
然后,每当父母更改传递的 fn
prop时,孩子必须从按钮中删除上一个单击的侦听器(以前的 fn
),并添加一个新的侦听器(刚刚传递的新 fn
)。
如果儿童组件与道具一起订阅了非dom事件,那么处理道具的更改可能为更困难处理。
因此,如果可能的话,希望通过稳定的道具传递稳定的道具 - 但是,如果儿童组件已经正确设计,那么几乎可以肯定的是,这两种方式都无关紧要。
请注意,创建实例变量的相同方法可以是:
const [onViewableItemsChanged] = useState(() => ({ viewableItems }) => {
setCurrentPageIndex(viewableItems[0].index ?? 0);
});
它具有与以下方式相同的效果:
const onViewableItemsChanged = useRef(({ viewableItems }) => {
setCurrentPageIndex(viewableItems[0].index ?? 0);
}).current;
因为参数中仅在组件安装时才发生的参数中的值。
最明显的事情是将它们写成常规功能,然后在代码中删除所有此
,因为它们已经是相当纯净的函数:
function MyComponent (props) {
[data, setData] = useState(processData(characterData));
[maxima, setMaxima] = useState(getMaxima(characterData));
function getMaxima (data) {
const groupedData = Object.keys(data[0]).reduce((memo, key) => {
memo[key] = data.map((d) => d[key]);
return memo;
}, {});
return Object.keys(groupedData).reduce((memo, key) => {
memo[key] = Math.max(...groupedData[key]);
return memo;
}, {});
}
function processData (data) {
const maxByGroup = getMaxima(data);
const makeDataArray = (d) => {
return Object.keys(d).map((key) => {
return { x: key, y: d[key] / maxByGroup[key] };
});
};
return data.map((datum) => makeDataArray(datum));
}
}
您可以通过在每个帖子中添加标签名称
作为类来过滤帖子。我希望这对你有帮助
function filterPosts(tag) {
const postsList = document.querySelectorAll('.tr-item');
if (tag === 'all') {
postsList.forEach(post => {
post.classList.remove('hidden');
});
} else {
postsList.forEach(post => {
if (post.classList.contains(tag)) {
post.classList.remove('hidden');
} else {
post.classList.add('hidden');
}
});
}
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.hidden {
display: none;
}
</style>
</head>
<body>
<div class="tr-nav">
<a href="#" onclick="filterPosts('all')">
<div class="tr-title ">All</div>
</a>
<a href="#" onclick="filterPosts('tag-1')">
<div class="tr-title">Tag 1</div>
</a>
<a href="#" onclick="filterPosts('tag-2')">
<div class="tr-title">Tag 2</div>
</a>
<a href="#" onclick="filterPosts('tag-3')">
<div class="tr-title ">Tag 3</div>
</a>
</div>
<div class="tr-wrap">
<div class="tr-list">
<div class="tr-item tag-3">
<h5>Lorem ipsum dolor sit amet, consectetur</h5>
<div class="tr-category">Tag 3</div>
</div>
<div class="tr-item tag-2">
<h5>Lorem ipsum dolor sit amet, consectetur</h5>
<div class="tr-category ">Tag 2</div>
</div>
<div class="tr-item tag-3">
<h5>Lorem ipsum dolor sit amet, consectetur</h5>
<div class="tr-category ">Tag 3</div>
</div>
<div class="tr-item tag-1">
<h5>Lorem ipsum dolor sit amet, consectetur</h5>
<div class="tr-category">Tag 1</div>
</div>
<div class="tr-item tag-2">
<h5>Lorem ipsum dolor sit amet, consectetur</h5>
<div class="tr-category ">Tag 2</div>
</div>
<div class="tr-item tag-3">
<h5>Lorem ipsum dolor sit amet, consectetur</h5>
<div class="tr-category">Tag 3</div>
</div>
</div>
</div>
</body>
</html>
试图编译该片段会告诉您到底发生了什么:
$ clang++ -std=c++17 test.cc -o test.bin -Iv8/include
test.cc:18:30: error: no matching constructor for initialization of 'v8::ScriptOrigin'
auto script_origin = new v8::ScriptOrigin(isolate, v8::String::NewFromUtf8(isolate, "main.mjs"));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./v8/include/v8-message.h:64:13: note: candidate constructor not viable: no known conversion from 'MaybeLocal<v8::String>' to 'Local<v8::Value>' for 2nd argument
V8_INLINE ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
^
./v8/include/v8-message.h:62:17: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class V8_EXPORT ScriptOrigin {
^
./v8/include/v8-message.h:62:17: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
1 error generated.
特别注意摘要
没有“ Maybelocal&lt; v8 :: string&gt;'的已知转换到'local&lt; v8 :: value&gt;'对于第二个参数
。
您正在尝试调用不存在的构造函数。您的IDE和编译器在报告此报告时是正确的。
创建新字符串可能会失败,特别是当请求的字符串太大时,因此 newstringfromutf8
返回 maybelocal
,强迫调用代码检查错误并适当处理它们。如果字符串与“ main.mjs”一样缩错误,因此总的来说,最好使用 bool
- 返回 .tolocal(...)
并优雅地处理错误)。
因此,如果将最后一行更改为:
auto script_origin = new v8::ScriptOrigin(
isolate,
v8::String::NewFromUtf8(isolate, "main.mjs").ToLocalChecked());
,则该片段将编译。
插入与此无关, v8_inline
宏或 nm
的输出或符号导出或其他与链接器相关的问题也不是无关的。不用说编辑V8的标头文件也不需要嵌入V8。
通常,在使用C ++时,可以清楚地区分编译器错误和链接器错误是有意义的。当编译器抱怨时,研究可能的链接问题是“吠叫错误的树”。
您是否尝试过安装您的道具,或者在调试时放断点?这对您有很大帮助!
无论如何,请尝试
<CalenderDate date ={array[0].date} />
小提示:请尝试避免使用键字作为变量名称,这很令人困惑,而且不可读取。我会说:从“阵列”切换到“ dateProp”或类似的东西。
小提示#2:始终牢记您使用的结构:
const array = [date:new Date(...)]一无所有。
我以为您想要一个数组,所以:
const myarray = []
然后,您想要其中一个或多个对象,因此:
const myarray = [{}]
每个对象都有一个键和一个值,所以:
const myarray = [{键:value,key2:value2,etc}]
是否需要更多的对象?然后去:
const myarray = [{key:value},{key2:value2},...,{keyn:valuen}]
You can set the list style:
我知道我知道某些领域会执行您提到的行为(如果在某个列表下显示按钮,则列表,如果列表,则)。但是我假设这与“自动”设置有关。请尝试设置使用建议的操作或您希望的任何格式,并查看是否有效。
您需要从表格中选择一个列。
从ID中的项目中选择SUM(量)(从TableName中选择COL1)
如果要获得匹配多个列的值,则内部选择应结合那些列。
从id中的项目中选择“ sum(量)
You need to select a column from the table.
SELECT Sum(amount) From items Where Id In (Select Col1 from TableName)
If you want to get values that match multiple columns, then the inner select should union those columns.
SELECT Sum(amount) From items Where Id In (Select Col1 from TableName Union Select Col2 from TableName)
如何获得与元组相似的数据?