清音悠歌

文章 评论 浏览 28

清音悠歌 2025-02-16 02:27:13

IF(a.ArticleNumber NOT IN ("204","204.2","204.3","204.4","204.5","204.6","204.7"),
   ROUND(SUM(r.DeliveredQuantity * IFNULL(a.DirectCost,a.PurchasePrice))),
   ROUND(SUM(SAFE_DIVIDE((r.DeliveredQuantity * IFNULL(a.DirectCost,a.PurchasePrice)) , (a.SalesPrice * i.CurrencyRate))))
  ) AS TG,

IF(a.ArticleNumber NOT IN ("204","204.2","204.3","204.4","204.5","204.6","204.7"),
   ROUND(SUM(r.DeliveredQuantity * IFNULL(a.DirectCost,a.PurchasePrice))),
   ROUND(SUM(SAFE_DIVIDE((r.DeliveredQuantity * IFNULL(a.DirectCost,a.PurchasePrice)) , (a.SalesPrice * i.CurrencyRate))))
  ) AS TG,

使用IFNULL语句中的Big-Query中使用If-Else语句

清音悠歌 2025-02-14 17:29:57

如果您有 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)

if you have json file first you need to read and after that, you can manipulate that data as a python object

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)

如何使用多个对象循环通过JSON数据

清音悠歌 2025-02-14 10:31:52

尝试此文件

    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)

Try this file

    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)

无法创建会话。未知错误:Chrome未能开始:被杀。 (未知错误:DevToolSactivePort文件不存在)

清音悠歌 2025-02-13 22:01:01

缓慢但有效的解决方案:

  1. 如果它们相等,请停止。
  2. 如果其中一个是0,则停止故障(如果不允许负数,则没有解决方案)。
  3. 虽然两者都大于1,但两者都减少。
  4. 现在较小的是1,另一个更大。
  5. 虽然较小的二元表示较短,但较小。
  6. 继续在步骤1。

在步骤4中,最大减少。在步骤5中,绝对差减小。因此,最终该算法终止。

A slow but working solution:

  1. If they are equal, stop.
  2. If one of them is 0, stop with failure (there is no solution if negative numbers are not allowed).
  3. While both are larger than 1, decrease both.
  4. Now the smaller is 1, the other is larger.
  5. While the smaller has a shorter binary representation, double the smaller.
  6. Continue at step 1.

In step 4, the maximum decreases. In step 5, the absolute difference decreases. Thus eventually the algorithm terminates.

同时使A和B平等的操作数量最少

清音悠歌 2025-02-13 06:01:19

事实证明,这个问题与另一个问题非常相似,尽管它们的措辞非常不同。

基本上,我需要做的是将脚本作为NT Authority \ System在启动时运行。 在Windows上运行无限命令服务器即使有人登录

As it turns out, this question is quite similar to another, though they're phrased very differently.

Basically, what I need to do is to run the script as NT AUTHORITY\System on startup. Run an infinite command on Windows Server even if someone is logged out

PowerShell团队消息包装器手动发送但不会自动发送

清音悠歌 2025-02-12 20:41:22

clientHeight clientwidth OffSetheight OffsetWidth height> height width 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'/>

clientHeight, clientWidth, offsetHeight, offsetWidth, height, width would give you relative dimensions. To get original dimensions you must use .naturalHeight and .naturalWidth.

HTMLImageElement.naturalWidth
The HTMLImageElement interface's read-only naturalWidth property returns the intrinsic (natural), density-corrected width of the image in CSS pixels.

This is the width the image is if drawn with nothing constraining its width; if you neither specify a width for the image nor place the image inside a container that limits or expressly specifies the image width, this is the number of CSS pixels wide the image will be.

You can read more here

You snippet can be updated with .naturalWidth and .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'/>


Also if you added an image just to get src you can try new Image() instead to skip creating an extra DOM element.

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'/>

JavaScript,如何从斑点获得图像宽度和高度?

清音悠歌 2025-02-12 06:48:31

我建议将您的内容放入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>

I would suggest putting your content into divs so that you may have more control over your elements.

<!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>

如何在段落的左侧设置图像?

清音悠歌 2025-02-12 05:26:49

看起来您的比较器仅检查 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 正确实现...

It looks like your comparator only checks for the case that a < b. Properly implemented comparators need to return not only 1 when a > b, but also 0 when a == b and -1 when a < b.

You could expand your if logic to cover those cases, but fortunately, there's an easier way - Integer.compare():

int result = Integer.compare(fact_a, fact_b);
if (result == 0) {
  result = Integer.compare(A1, B);
}
return result;

Integer.compare() handles most of the logic for you; the only thing you need to do is check if the result of the factor comparison is 'equal', and if so, apply the fallback comparison of the numbers themselves

(note: for the sake of this answer I'm assuming that calcFactors is implemented properly...)

基于使用Java中的自定义比较器的因素进行排序

清音悠歌 2025-02-11 19:21:11

如果有人有这个问题(当您使用脚本生成世界并在其中添加nav2d的东西时),然后用 get_simple_path - 使用 yarks(get_tree(),“ idle_frame”)< /code>并将您的 get_simple_path 放入代码的另一个函数或块中,只需以某种方式将其与主代码分开。我只是这样做了,它运行得很好。我从此线程。

If anyone has this problem (when you generate world with a script and add Nav2D stuff to it), before calculating the path with get_simple_path - use yield(get_tree(), "idle_frame") AND put your get_simple_path into another function or block of code, just separate it from the main code somehow. I did just that and it works perfectly. I got the solution from this thread.

navigation2D get_simple_path返回poolvector2Array大小:0

清音悠歌 2025-02-11 13:53:42

如果使用数组类型参数,则应将值作为正确的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消息中,数组被描绘为重复元素,如上所示。

If you are using the array type parameters you should pass the values as a proper JSON array. Something like this will work for you.

The Request:

{
  "_poststudent": {
    "code": ["AXB23","ADR40"]
  }
}

Dataservice Query

<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>

Update

The Full Dataservice config.

<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>

Note that I have specified a <resource method="POST" path="student">. resources are for RESTfull invocations, and <operation name="selectTEST" returnRequestStatus="true"> are for SOAP calls. I have created both RestFul and SOAP services for your reference. Following is how you can invoke them.

Note: Here I'm directly calling the Dataservice.

RestFull Invocation.

curl --location --request POST 'http://localhost:8290/services/RESTDataService/student' \
--header 'Content-Type: application/json' \
--data-raw '{
  "students": {
    "code": ["AXB23", "ADR40"]
  }
}'

SOAP Service Call

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>'

Note: In a XML message an Array is depicted as repeating elements as shown above.

ESB WSO2-在数据源查询中使用数组作为paramtype

清音悠歌 2025-02-11 11:57:32

如果其他语句在对象初始化中,则不能使用。您只能将其分配给那里的公共写作(即具有设置器的属性)属性。
如下面的一评论所建议的那样,从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)
    };

You can't use an if else statement inside an object initialization. You can only assign to public writable (that is, properties having a setter) properties there.
As suggested in one comment below, starting from C# 9 you can also set init-only properties when using object initialization syntax. These properties can be written only during object construction, once the object construction phase is completed you are not allowed to write the property.
Regardless of the C# language version, you can't use any control flow statement in object initialization.

A working version of your code is the following:

    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)
    };

如果其他语句在本地变量/类中

清音悠歌 2025-02-11 07:17:56

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>

UPDATE: the original answer assumed from the question that the image was an HTML img. The solution was to set width to 100% [of its container] and height to 70vh and use object-fit.

However, it is not an img it is a canvas.

The required aspect ratio is known to be 16 / 9. This snippet therefore sets the max-width to 100% (of whatever is the container) and the max-height to 70vh.

This way there can never be any overflow and the canvas will be as big as it can be within those constraints.

body {
  width: 100vw;
  margin: 0;
}

canvas {
  max-width: 100%;
  max-height: 70vh;
  aspect-ratio: 16 / 9;
  background: green;
}
<canvas width="1600" height="900"></canvas>

如何确保高度不超过父的高度,同时还要维护图像的纵横比

清音悠歌 2025-02-11 04:25:59

使用

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

Use merge_asof

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`
             )

Output:

  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

PANDAS-使用第二个DataFrame作为该函数的输入,在列上应用功能?

清音悠歌 2025-02-10 22:05:24

您的代码需要首先在etherscan上发布。

Your code needs to be published on Etherscan first.

NFT从自定义ERC-1155智能合约未正确显示在etherscan上的Goerli测试网

清音悠歌 2025-02-10 19:05:34
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-─────-─-─-─-─-─-─-─杏仁 - ─-─..- - ─-

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()

Do not use a variable to pass the argument of sleep (), you must insert the calculation directly into sleep ()


And the return of my terminal

1 ───── 17:20:16.891 ───────────────────

2 ───── 17:20:18.891 ───────────────────

3 ───── 17:20:20.891 ───────────────────

4 ───── 17:20:22.891 ───────────────────

5 ───── 17:20:24.891 ───────────────────

....

689 ─── 17:43:12.891 ────────────────────

690 ─── 17:43:14.890 ────────────────────

691 ─── 17:43:16.891 ────────────────────

692 ─── 17:43:18.890 ────────────────────

693 ─── 17:43:20.891 ────────────────────

...

727 ─── 17:44:28.891 ────────────────────

728 ─── 17:44:30.891 ────────────────────

729 ─── 17:44:32.891 ────────────────────

730 ─── 17:44:34.890 ────────────────────

731 ─── 17:44:36.891 ────────────────────

python的time.sleep()有多准确?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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