如果您有 JSON
首先需要阅读,则可以将数据操纵为Python对象
import json
with open("data.json") as json_file:
data = json.load(json_file)
for d in data:
host = d['host']
username = d['username']
path = d['path']
print(host, username, path)
尝试此文件
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--no-sandbox");
options.add_argument("--headless")
options.add_argument("--disable-setuid-sandbox")
options.add_argument("--remote-debugging-port=9222") # this
options.add_argument("--disable-extensions")
#options.add_argument("--headless")
options.add_argument("--disable-gpu")
options.add_argument("enable-automation")
options.add_argument("--disable-infos")
options.add_argument("--disable-dev-shm-usage")
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://www.google.com/")
element_text = driver.page_source
print(element_text)
缓慢但有效的解决方案:
- 如果它们相等,请停止。
- 如果其中一个是0,则停止故障(如果不允许负数,则没有解决方案)。
- 虽然两者都大于1,但两者都减少。
- 现在较小的是1,另一个更大。
- 虽然较小的二元表示较短,但较小。
- 继续在步骤1。
在步骤4中,最大减少。在步骤5中,绝对差减小。因此,最终该算法终止。
事实证明,这个问题与另一个问题非常相似,尽管它们的措辞非常不同。
基本上,我需要做的是将脚本作为NT Authority \ System在启动时运行。 在Windows上运行无限命令服务器即使有人登录
clientHeight
, clientwidth
, OffSetheight
, OffsetWidth
, height> height
, width
/代码>将为您提供相对尺寸。要获取原始尺寸,您必须使用 .naturalheight
和 .naturalAlalWidth
。
htmlimageelement.naturalwidth
HTMLIMAGEELEMENT界面的仅读取天然宽属性返回CSS像素中图像的固有(天然),密度校正的宽度。这是图像绘制的宽度,没有限制其宽度;如果您既没有为图像指定宽度,也没有将图像放入限制或明确指定图像宽度的容器中href =“ https://developer.mozilla.org/en-us/docs/web/api/htmlimageelement/naturalwidth” rel =“ noreferrer”>在这里
href =“ https://developer.mozilla.org/en-us/docs/web/api/htmlemageelement/naturalalwidth” rel =“ noreferrer /code>和 .naturalheight
as
let imgInput = document.getElementById('id_photo');
imgInput.addEventListener('change', function (e) {
if (e.target.files) {
for (let i = 0; i < e.target.files.length; i++) {
let imageFile = e.target.files[i];
var reader = new FileReader();
reader.onload = function (e) {
var img = document.getElementById('displayImage');
img.onload = function() {
debugger;
var shape = resizeImage(img) // resizing image for future canvas drawing, returns [width, height] (resized)
// or just
// var shape = [image.naturalWidth, image.naturalHeight]
var canvas = document.createElement("canvas")
canvas.width = shape[0]
canvas.height = shape[1]
var ctx = canvas.getContext("2d")
ctx.drawImage(img, 0, 0, shape[0], shape[1])
document.body.appendChild(canvas); // added
// converting to base64 logic and the rest code
}
img.src = e.target.result;
}
reader.readAsDataURL(imageFile);
}
}
});
function resizeImage(image){
return [image.naturalWidth, image.naturalHeight]
}
img{
width: 100px;
heigh: 100px;
}
<img id='displayImage'/>
<input type='file' multiple id='id_photo'/>
另外,如果仅添加了一个图像以获取SRC,则可以尝试 new Image()
而不是跳过创建额外的DOM元素。
let imgInput = document.getElementById('id_photo');
imgInput.addEventListener('change', function (e) {
if (e.target.files) {
Array.from(e.target.files).forEach(file=>{
const fileReader = new FileReader();
fileReader.readAsDataURL(file);
fileReader.onload = (fe) => {
const image = new Image();
image.src = fe.currentTarget.result;
image.onload = function(ie){
console.log('Width: ' + this.naturalHeight);
console.log('Height: ' + this.naturalWidth);
}
}
})
}
});
<input type='file' multiple id='id_photo'/>
我建议将您的内容放入Divs,以便您可以更好地控制自己的元素。
<!DOCTYPE html>
<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>
.container{
display: flex;
vertical-align: middle;
margin: 0 auto;
justify-content: left;
align-items: center;
gap:10px;
}
</style>
</head>
<body>
<div class="container">
<div>
<img src="./HomePagePictureBlackWhite.jpg" alt="LeeBlackWhite">
</div>
<div>
<p>
"Paragraph text"
</p>
</div>
</div>
</body>
</html>
看起来您的比较器仅检查 a&lt; B
。正确实现的比较器不仅需要返回 1
a&gt; b
,但 0
当 a == b
和 -1
时, a&lt; B
。
您可以扩展如果
逻辑以涵盖这些情况,但是幸运的是,有一种更简单的方法-e integer.compare():
int result = Integer.compare(fact_a, fact_b);
if (result == 0) {
result = Integer.compare(A1, B);
}
return result;
integer.compare()
处理大部分逻辑;您唯一需要做的是检查因子比较的结果是否为“相等”,如果是,则应用数字本身的后备比较
(注意:为了这个答案,我假设我假设 calcfactor
正确实现...
如果使用数组类型参数,则应将值作为正确的JSON数组传递。这样的事情对您有用。
请求:
{
"_poststudent": {
"code": ["AXB23","ADR40"]
}
}
dataService查询
<query id="CreateStudents" useConfig="default">
<sql>SELECT id, name, school, grade FROM students WHERE grade IN (:code)</sql>
<param name="code" paramType="ARRAY" sqlType="STRING" type="IN" optional="false" />
<result outputType="json">{"students":{"student":[{"name":"$name","school":"$school","grade":"$grade"}]}}{"students":{"student":[{"name":"$name","school":"$school","grade":"$grade"}]}}{"students":{"student":[{"name":"$name","school":"$school","grade":"$grade"}]}}{"students":{"student":[{"name":"$name","school":"$school", "grade":"$grade"}]}}{"students":{"student":[{"name":"$name","school":"$school","grade":"$grade"}]}}{"students":{"student":[{"name":"$name","school":"$school","grade":"$grade"}]}}{"students":{"student":[{"name":"$name","school":"$school", "grade":"$grade"} ] }}{"students":{"student":[{"name":"$name","school":"$school","grade":"$grade"} ] } }</result>
</query>
更新
完整的数据服务配置。
<data name="RESTDataService" serviceNamespace="http://ws.wso2.org/dataservice/samples/json_sample" transports="http https">
<description>Exposing the data service as a REST service.</description>
<config id="default">
<property name="driverClassName">com.mysql.jdbc.Driver</property>
<property name="url">jdbc:mysql://localhost:3306/school_db</property>
<property name="org.wso2.ws.dataservice.user">xxxxx</property>
<property name="org.wso2.ws.dataservice.password">xxxxx</property>
</config>
<resource method="POST" path="student">
<call-query href="ReadStudents">
<with-param name="code" query-param="code" />
</call-query>
</resource>
<operation name="selectTEST" returnRequestStatus="true">
<call-query href="ReadStudents">
<with-param name="code" query-param="code" />
</call-query>
</operation>
<query id="ReadStudents" useConfig="default">
<sql>SELECT id, name, school, grade FROM students WHERE grade IN (:code)</sql>
<param name="code" paramType="ARRAY" sqlType="STRING" type="IN" optional="false" />
<result outputType="json">{ "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } { "students":{ "student":[ { "name":"$name", "school":"$school", "grade":"$grade" } ] } } </result>
</query>
</data>
请注意,我已经指定了&lt;资源方法=“ path”路径=“ student”&gt;
。资源用于RESTFULL INCOCACTICS,&lt;操作名称=“ selectTest” returnRequestStatus =“ true”&gt;
用于肥皂调用。我已经创建了Rentful and SOAP服务供您参考。以下是您可以调用它们的方式。
注意:这里我直接调用数据服务。
RESTFULL调用。
curl --location --request POST 'http://localhost:8290/services/RESTDataService/student' \
--header 'Content-Type: application/json' \
--data-raw '{
"students": {
"code": ["AXB23", "ADR40"]
}
}'
SOAP服务调用
curl --location --request POST 'http://localhost:8290/services/RESTDataService/selectTEST' \
--header 'Action: selectTEST' \
--header 'Content-Type: text/xml' \
--header 'Accept: application/json' \
--data-raw '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/">
<soap:Body>
<code>AXB23</code>
<code>ADR40</code>
</soap:Body>
</soap:Envelope>'
注意:在XML消息中,数组被描绘为重复元素,如上所示。
如果其他语句在对象初始化中,则不能使用。您只能将其分配给那里的公共写作(即具有设置器的属性)属性。
如下面的一评论所建议的那样,从C#9开始,您也可以设置 init-forly属性。这些属性可以在对象构造过程中仅写成 ,一旦对象构造阶段完成,您 允许撰写属性。
无论C#语言版本如何,您都不能在对象初始化中使用任何控制流语句。
您的代码的工作版本如下:
string isActive = chkIsActive.Checked ? "Yes": "No";
var account = new UserAccount()
{
FirstName = txtFirstName.Text,
LastName = txtLastName.Text,
Email = txtEmail.Text,
TeamName = txtTeamName.Text,
Password = txtPassword.Text,
IsActive = isActive,
UserId = int.Parse(txtUserId.Text)
};
Update :从一个问题中假定的原始答案是图像是HTML IMG。解决方案是将宽度设置为[其容器的100%],并将高度设置为70VH,并使用对象拟合。
但是,这不是IMG,而是画布。
已知所需的纵横比为16/9。因此,该段将最大宽度设置为100%(任何是容器的)和最大高点为70VH。
这样,永远不会有任何溢出,画布将在这些约束中尽可能大。
body {
width: 100vw;
margin: 0;
}
canvas {
max-width: 100%;
max-height: 70vh;
aspect-ratio: 16 / 9;
background: green;
}
<canvas width="1600" height="900"></canvas>
pd.merge_asof(df.sort_values('strike'), # must be sorted by key
support.sort_values('Values'), # must be sorted by key
left_on='strike',
right_on='Values',
direction='backward', # default, so `Values <= strike`
allow_exact_matches=False # so that `Values != strike`
)
输出:
name strike Values Confidence R/S
0 dfg 6 NaN NaN NaN
1 xyz 12 10.0 3.0 S
2 ghf 40 35.0 12.0 S
您的代码需要首先在etherscan上发布。
def start(self):
sec_arg = 10.0
cptr = 0
time_start = time.time()
time_init = time.time()
while True:
cptr += 1
time_start = time.time()
time.sleep(((time_init + (sec_arg * cptr)) - time_start ))
# AND YOUR CODE .......
t00 = threading.Thread(name='thread_request', target=self.send_request, args=([]))
t00.start()
请勿使用变量传递睡眠()的参数,必须将计算直接插入睡眠()
流度返回
和我的终端1�I-− ()。 ──────────-
─-─-2-─-─-─-17:20:20:18.891-──杏仁 - ─-─-─-─-─-─-─-─-─杏仁 - 前往─-─-─-─-─-─-
3-─-─-─-─- 17:20: 20.891-─-─-─-─-─-─-─-─-─-─- - ─-─-─-─-─-4
-─-─-─返来语17:20:22.891-─前
5- - ─-─-17:20:20:24.891--───杏仁 - ─-─-─-─-─-─-─-─-─-─-─-─-689
-
─-─-─-─-─-─-17:43:12.891- ─────
-─-─-─-─-─- - ─-─-690--─-17:43:43:14.890-─-─-─-─-─-─-─-─-─-─-─-
─杏仁 - ─-─ -─-─-─-─-─-─-─-丁 - ─-丁16.891-─-─-─-─-─-─-─-─-─-─-─- - ─- - ─-─-─
-─-─-─-─-─返来
693- - ─-17:43:43:20.891
-────-─-─-─-─-─-─-─-─-─-─-─-─-─---─-727-─ -─
-─-─-─-─--─--─--─-─-─--─-─---─--─- 返
- ─-─-─-─-─-─-─-─-─-728-─
来────
-─-─-─-─-─-─-─-─-─-─- - ─-─--───返
来────17:44:36.891-─────-─-─-─-─-─-─-─杏仁 - ─-─..- - ─-
使用IFNULL语句中的Big-Query中使用If-Else语句