≈。彩虹

文章 评论 浏览 30

≈。彩虹 2025-02-20 23:50:54

如果您的代码在Python 2和3中都可以使用,则可以通过在程序开始时加载它来实现此目标:

from __future__ import print_function   # If code has to work in Python 2 and 3!

然后,您可以以Python 3方式打印:

print("python")

如果您想打印某些东西而不创建新行 - 您可以可以这样做:

for number in range(0, 10):
    print(number, end=', ')

If your code should work in both Python 2 and 3, you can achieve this by loading this at the beginning of your program:

from __future__ import print_function   # If code has to work in Python 2 and 3!

Then you can print in the Python 3 way:

print("python")

If you want to print something without creating a new line - you can do this:

for number in range(0, 10):
    print(number, end=', ')

“语法”是什么:在呼叫到“ print”中缺少括号。在python中的意思?

≈。彩虹 2025-02-20 12:39:33

document.getElementById中,您忘了将``''添加到mullkompressenamount id。

固定的:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <table>
    <tr>
      <th>Kosmetikartikel</th>
      <th>Menge</th>
    </tr>
    <tr>
      <td>Waschlotion</td>
      <td><input id="WaschlotionAmount"></td>
    </tr>
    <tr>
      <td>Haarshampoo</td>
      <td><input id="HaarshampooAmount"></td>
    </tr>
    <tr>
      <td>Bodylotion</td>
      <td><input id="BodylotionAmount"></td>
    </tr>
    <tr>
      <td>Wundschutzcreme</td>
      <td><input id="WundschutzcremeAmount"></td>
    </tr>
    <tr>
      <td>Deospray</td>
     <td><input id="DeosprayAmount"></td>
   </tr>
   <tr>
    <td>Zahncreme</td>
    <td><input id="ZahncremeAmount"></td>
  </tr>
  <tr>
   <td>Zahnbürste</td>
   <td><input id="ZahnbuersteAmount"></td>
 </tr>
 <tr>
  <td>Zahnspüllbecher</td>
  <td><input id="ZahnspuellbecherAmount"></td>
</tr>
   <tr>
    <td>Zahnhaftcreme</td>
    <td><input id="ZahnhaftcremeAmount"></td>
  </tr>
  <tr>
    <td>Zahnreinigunstabs</td>
    <td><input id="ZahnreinigunstabsAmount"></td>
  </tr>
  <tr>
    <td>Rasierklingen</td>
    <td><input id="RasierklingenAmount"></td>
  </tr>
  <tr>
    <td>Rasierer mit Klingen</td>
    <td><input id="RasiererMitKlingenAmount"></td>
  </tr>
  <tr>
    <td>Rasierschaum</td>
    <td><input id="RasierschaumAmount"></td>
  </tr>
  <tr>
    <td>Einwegrasierer</td>
    <td><input id="EinwegrasiererAmount"></td>
  </tr>
  <tr>
    <td>Zahnreinigunsbecher</td>
    <td><input id="ZahnreinigunsBecherAmount"></td>
  </tr>
  <tr>
    <td>Mullkompressen</td>
    <td><input id="MullkompressenAmount"></td>
  </tr>
  <tr>
    <td><b>Gesamtpreis</b></td>
    <td><p id="Sum"></p></td>
  </tr>
</table>

<button onclick="Calculate()">Rechnen</button>
<button  onclick="document.getElementById(`MullkompressenAmount`).value = ''">Löschen</button>
</body>
<script>
var Waschlotion = 1.30;
var Haarshampoo = 1.50;
var Bodylotion = 3;
var Wundschutzcreme = 4.80;
var Deospray = 1.80;
var Zahncreme = 3.20;
var Zahnbuerste = 1;
var Zahnspuellbecher = 1.25;
var Zahnhaftcreme = 1.50;
var Zahnreinigunstabs = 3.20;
var Rasierklingen = 2.49;
var RasiererMitKlingen = 4.50;
var Rasierschaum = 1.40;
var Einwegrasierer = 2;
var ZahnreinigunsBecher = 5;
var Mullkompressen = 6;

let Sum;

let WaschlotionAmount;
let HaarshampooAmount;
let BodylotionAmount;
let WundschutzcremeAmount;
let DeosprayAmount;
let ZahncremeAmount;
let ZahnbuersteAmount;
let ZahnspuellbecherAmount;
let ZahnhaftcremeAmount;
let ZahnreinigunstabsAmount;
let RasierklingenAmount;
let RasiererMitKlingenAmount;
let RasierschaumAmount;
let EinwegrasiererAmount;
let ZahnreinigunsBecherAmount;
let MullkompressenAmount;



function Calculate() {
  if (Sum != 0) {
    Sum = 0;
  }
  let WaschlotionAmount = document.getElementById("WaschlotionAmount").value;
  let HaarshampooAmount = document.getElementById("HaarshampooAmount").value;
  let BodylotionAmount = document.getElementById("BodylotionAmount").value;
  let WundschutzcremeAmount = document.getElementById("WundschutzcremeAmount").value;
  let DeosprayAmount = document.getElementById("DeosprayAmount").value;
  let ZahncremeAmount = document.getElementById("ZahncremeAmount").value;
  let ZahnbuersteAmount = document.getElementById("ZahnbuersteAmount").value;
  let ZahnspuellbecherAmount = document.getElementById("ZahnspuellbecherAmount").value;
  let ZahnhaftcremeAmount = document.getElementById("ZahnhaftcremeAmount").value;
  let ZahnreinigunstabsAmount = document.getElementById("ZahnreinigunstabsAmount").value;
  let RasierklingenAmount = document.getElementById("RasierklingenAmount").value;
  let RasiererMitKlingenAmount = document.getElementById("RasiererMitKlingenAmount").value;
  let RasierschaumAmount = document.getElementById("RasierschaumAmount").value;
  let EinwegrasiererAmount = document.getElementById("EinwegrasiererAmount").value;
  let ZahnreinigunsBecherAmount = document.getElementById("ZahnreinigunsBecherAmount").value;
  let MullkompressenAmount = document.getElementById("MullkompressenAmount").value;

  Sum = (Waschlotion * WaschlotionAmount) + (Haarshampoo * HaarshampooAmount) + (Bodylotion * BodylotionAmount) +
  (Wundschutzcreme * WundschutzcremeAmount) + (Deospray * DeosprayAmount) + (Zahncreme * ZahncremeAmount) +
  (Zahnbuerste * ZahnbuersteAmount) + (Zahnspuellbecher * ZahnspuellbecherAmount) + (Zahnhaftcreme * ZahnhaftcremeAmount) +
  (Zahnreinigunstabs * ZahnreinigunstabsAmount) + (Rasierklingen * RasierklingenAmount) + (RasiererMitKlingen * RasiererMitKlingenAmount) +
  (Rasierschaum * RasierschaumAmount) + (Einwegrasierer * EinwegrasiererAmount) + (ZahnreinigunsBecher * ZahnreinigunsBecherAmount) + (Mullkompressen * MullkompressenAmount);
  document.getElementById("Sum").innerHTML = Sum;
}


 </script>
</html>

In document.getElementById you forgot to add `` to the MullkompressenAmount id.

Fixed:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <table>
    <tr>
      <th>Kosmetikartikel</th>
      <th>Menge</th>
    </tr>
    <tr>
      <td>Waschlotion</td>
      <td><input id="WaschlotionAmount"></td>
    </tr>
    <tr>
      <td>Haarshampoo</td>
      <td><input id="HaarshampooAmount"></td>
    </tr>
    <tr>
      <td>Bodylotion</td>
      <td><input id="BodylotionAmount"></td>
    </tr>
    <tr>
      <td>Wundschutzcreme</td>
      <td><input id="WundschutzcremeAmount"></td>
    </tr>
    <tr>
      <td>Deospray</td>
     <td><input id="DeosprayAmount"></td>
   </tr>
   <tr>
    <td>Zahncreme</td>
    <td><input id="ZahncremeAmount"></td>
  </tr>
  <tr>
   <td>Zahnbürste</td>
   <td><input id="ZahnbuersteAmount"></td>
 </tr>
 <tr>
  <td>Zahnspüllbecher</td>
  <td><input id="ZahnspuellbecherAmount"></td>
</tr>
   <tr>
    <td>Zahnhaftcreme</td>
    <td><input id="ZahnhaftcremeAmount"></td>
  </tr>
  <tr>
    <td>Zahnreinigunstabs</td>
    <td><input id="ZahnreinigunstabsAmount"></td>
  </tr>
  <tr>
    <td>Rasierklingen</td>
    <td><input id="RasierklingenAmount"></td>
  </tr>
  <tr>
    <td>Rasierer mit Klingen</td>
    <td><input id="RasiererMitKlingenAmount"></td>
  </tr>
  <tr>
    <td>Rasierschaum</td>
    <td><input id="RasierschaumAmount"></td>
  </tr>
  <tr>
    <td>Einwegrasierer</td>
    <td><input id="EinwegrasiererAmount"></td>
  </tr>
  <tr>
    <td>Zahnreinigunsbecher</td>
    <td><input id="ZahnreinigunsBecherAmount"></td>
  </tr>
  <tr>
    <td>Mullkompressen</td>
    <td><input id="MullkompressenAmount"></td>
  </tr>
  <tr>
    <td><b>Gesamtpreis</b></td>
    <td><p id="Sum"></p></td>
  </tr>
</table>

<button onclick="Calculate()">Rechnen</button>
<button  onclick="document.getElementById(`MullkompressenAmount`).value = ''">Löschen</button>
</body>
<script>
var Waschlotion = 1.30;
var Haarshampoo = 1.50;
var Bodylotion = 3;
var Wundschutzcreme = 4.80;
var Deospray = 1.80;
var Zahncreme = 3.20;
var Zahnbuerste = 1;
var Zahnspuellbecher = 1.25;
var Zahnhaftcreme = 1.50;
var Zahnreinigunstabs = 3.20;
var Rasierklingen = 2.49;
var RasiererMitKlingen = 4.50;
var Rasierschaum = 1.40;
var Einwegrasierer = 2;
var ZahnreinigunsBecher = 5;
var Mullkompressen = 6;

let Sum;

let WaschlotionAmount;
let HaarshampooAmount;
let BodylotionAmount;
let WundschutzcremeAmount;
let DeosprayAmount;
let ZahncremeAmount;
let ZahnbuersteAmount;
let ZahnspuellbecherAmount;
let ZahnhaftcremeAmount;
let ZahnreinigunstabsAmount;
let RasierklingenAmount;
let RasiererMitKlingenAmount;
let RasierschaumAmount;
let EinwegrasiererAmount;
let ZahnreinigunsBecherAmount;
let MullkompressenAmount;



function Calculate() {
  if (Sum != 0) {
    Sum = 0;
  }
  let WaschlotionAmount = document.getElementById("WaschlotionAmount").value;
  let HaarshampooAmount = document.getElementById("HaarshampooAmount").value;
  let BodylotionAmount = document.getElementById("BodylotionAmount").value;
  let WundschutzcremeAmount = document.getElementById("WundschutzcremeAmount").value;
  let DeosprayAmount = document.getElementById("DeosprayAmount").value;
  let ZahncremeAmount = document.getElementById("ZahncremeAmount").value;
  let ZahnbuersteAmount = document.getElementById("ZahnbuersteAmount").value;
  let ZahnspuellbecherAmount = document.getElementById("ZahnspuellbecherAmount").value;
  let ZahnhaftcremeAmount = document.getElementById("ZahnhaftcremeAmount").value;
  let ZahnreinigunstabsAmount = document.getElementById("ZahnreinigunstabsAmount").value;
  let RasierklingenAmount = document.getElementById("RasierklingenAmount").value;
  let RasiererMitKlingenAmount = document.getElementById("RasiererMitKlingenAmount").value;
  let RasierschaumAmount = document.getElementById("RasierschaumAmount").value;
  let EinwegrasiererAmount = document.getElementById("EinwegrasiererAmount").value;
  let ZahnreinigunsBecherAmount = document.getElementById("ZahnreinigunsBecherAmount").value;
  let MullkompressenAmount = document.getElementById("MullkompressenAmount").value;

  Sum = (Waschlotion * WaschlotionAmount) + (Haarshampoo * HaarshampooAmount) + (Bodylotion * BodylotionAmount) +
  (Wundschutzcreme * WundschutzcremeAmount) + (Deospray * DeosprayAmount) + (Zahncreme * ZahncremeAmount) +
  (Zahnbuerste * ZahnbuersteAmount) + (Zahnspuellbecher * ZahnspuellbecherAmount) + (Zahnhaftcreme * ZahnhaftcremeAmount) +
  (Zahnreinigunstabs * ZahnreinigunstabsAmount) + (Rasierklingen * RasierklingenAmount) + (RasiererMitKlingen * RasiererMitKlingenAmount) +
  (Rasierschaum * RasierschaumAmount) + (Einwegrasierer * EinwegrasiererAmount) + (ZahnreinigunsBecher * ZahnreinigunsBecherAmount) + (Mullkompressen * MullkompressenAmount);
  document.getElementById("Sum").innerHTML = Sum;
}


 </script>
</html>

我的按钮清除所有输入字段无法工作

≈。彩虹 2025-02-19 16:48:13

我曾经有同样的问题。我从build.gradle

//实现平台上删除firebase('com.google.firebase:firebase-bom:29.0.4')

也将firebase降级到29.0.2也正在工作。

I had the same issue with Flutter. I remove Firebase from build.gradle

// implementation platform('com.google.firebase:firebase-bom:29.0.4')

also downgrading firebase to 29.0.2 is working too.

superClass androidx.core.app.f of androidx.activity.com宣称最终

≈。彩虹 2025-02-19 12:34:40

昨晚遇到了同样的问题,我的所有计划无头测试。

无论是否登录用户,它们都会运行,并且不存储密码。我没有使用具有最高特权的运行。

这些动作是完整的路径,而无需使用Run。

不确定为什么他们在2 1/2年(其中一些)跑步时会大大失败。

Had the same issue last night will all of my scheduled headless tests.

They are Run whether user is logged on or not and Do Not Store Password. I have not used Run with highest privileges.

The actions are full path without using Run In.

Not sure why they would massively fail when they've been running (some of them) for 2 1/2 years.

收到错误和“ 0x1”在Windows任务时间表中

≈。彩虹 2025-02-19 07:06:32

您必须使用getfullinfo方法。

此外,MTPROTO客户端不能总是从ID开始的用户解决:他们必须在某些其他上下文(一个私人聊天,一个组)之前与用户见面,以缓存他们的信息。
用户名还可以触发此信息的缓存:尝试传递用户名而不是ID。

MadelineProto还具有可选的cacheallpeersonStartup 可以启用对话框列表中的所有用户和组自动启动。

You must use the getFullInfo method, instead.

Also, MTProto clients can't always resolve a user starting from their ID: they must've met the user before in some other context (a private chat, a group) in order to cache their information.
A username can also trigger caching of this information: try passing your username instead of your ID.

MadelineProto also has an optional cacheAllPeersOnStartup setting that can be enabled to pre-cache all users and groups in the dialog list on startup automatically.

MadelineProto内部同行数据库错误尝试GetfulLuser时

≈。彩虹 2025-02-18 19:01:04

使用控制器添加listView。考虑一张高度200的卡。现在,如果控制器偏移量为800,则播放该800/200的视频。这是第四。您可以使用任何可以选择并停止视频的视频播放器软件包

Add a listview with a controller. consider a card of height 200. Now if the controller offset is 800 play the video of that 800/200. Which is 4th one. You can use any video player package which has an option to statt and stop video

如何自动播放视频,例如flutter上的YouTube应用程序中的视频?

≈。彩虹 2025-02-18 14:25:36

尝试以下操作:(创建扩展方法)

public static List<T> ExecuteQuery<T>(this dbContext db, string query) where T : class, new()
        {
            using (var command = db.Database.GetDbConnection().CreateCommand())
            {
                command.CommandText = query;
                command.CommandType = CommandType.Text;

                db.Database.OpenConnection();

                using (var reader = command.ExecuteReader())
                {
                    var lst = new List<T>();
                    var lstColumns = new T().GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList();
                    while (reader.Read())
                    {
                        var newObject = new T();
                        for (var i = 0; i < reader.FieldCount; i++)
                        {
                            var name = reader.GetName(i);
                            PropertyInfo prop = lstColumns.FirstOrDefault(a => a.Name.ToLower().Equals(name.ToLower()));
                            if (prop == null)
                            {
                                continue;
                            }
                            var val = reader.IsDBNull(i) ? null : reader[i];
                            prop.SetValue(newObject, val, null);
                        }
                        lst.Add(newObject);
                    }

                    return lst;
                }
            }
        }

用法:

var db = new dbContext();
string query = @"select ID , Name from People where ... ";
var lst = db.ExecuteQuery<PeopleView>(query);

我的模型:(不在dbset中):

public class PeopleView
{
    public int ID { get; set; }
    public string Name { get; set; }
}

.netcore 2.2和3.0中测试。

注意:此解决方案的性能缓慢

try this: (create extension method)

public static List<T> ExecuteQuery<T>(this dbContext db, string query) where T : class, new()
        {
            using (var command = db.Database.GetDbConnection().CreateCommand())
            {
                command.CommandText = query;
                command.CommandType = CommandType.Text;

                db.Database.OpenConnection();

                using (var reader = command.ExecuteReader())
                {
                    var lst = new List<T>();
                    var lstColumns = new T().GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList();
                    while (reader.Read())
                    {
                        var newObject = new T();
                        for (var i = 0; i < reader.FieldCount; i++)
                        {
                            var name = reader.GetName(i);
                            PropertyInfo prop = lstColumns.FirstOrDefault(a => a.Name.ToLower().Equals(name.ToLower()));
                            if (prop == null)
                            {
                                continue;
                            }
                            var val = reader.IsDBNull(i) ? null : reader[i];
                            prop.SetValue(newObject, val, null);
                        }
                        lst.Add(newObject);
                    }

                    return lst;
                }
            }
        }

Usage:

var db = new dbContext();
string query = @"select ID , Name from People where ... ";
var lst = db.ExecuteQuery<PeopleView>(query);

my model: (not in DbSet):

public class PeopleView
{
    public int ID { get; set; }
    public string Name { get; set; }
}

tested in .netCore 2.2 and 3.0.

Note: this solution has the slow performance

RAW SQL查询无DBSET-实体框架核心

≈。彩虹 2025-02-18 13:52:58

根据 plotly document 在时间序列上,您可以使用update_xaxes更改X轴标签的出现和格式的方法:

fig = go.Figure()
fig.add_trace(go.Scatter(x=df1["month"], y=df1["counts"], name="counts history"))
fig.update_xaxes(dtick="M1", tickformat="%Y-%m")
fig.show()

As per the plotly documentation on time series, you can use the update_xaxes method to change the ocurrence and format of the x-axis labels:

fig = go.Figure()
fig.add_trace(go.Scatter(x=df1["month"], y=df1["counts"], name="counts history"))
fig.update_xaxes(dtick="M1", tickformat="%Y-%m")
fig.show()

enter image description here

Plotly Graph不能正确显示X轴值

≈。彩虹 2025-02-18 12:17:38

您应该逐个类型,而不是类型的数组。它是一个包含数组的单个对象,但根JSON不是数组。

var birdRecords = JsonConvert.DeserializeObject<birdDataSolutionVM>(data);

You should be deserializing into the type, not an array of the type. It's a single object containing an array, but the root json is not an array.

var birdRecords = JsonConvert.DeserializeObject<birdDataSolutionVM>(data);

jsonconvert.deserializeObject错误,当时启用字符串

≈。彩虹 2025-02-18 11:18:37

在for循环外部写下Console.Writeline(),以避免在每个步骤中打印它。

Write the console.WriteLine() Outside the for loop to avoid printing it in every step.

我是在计算系列中的数字总和,但我只希望控制台输出最终总和,但我不知道如何

≈。彩虹 2025-02-18 09:40:09

在许多情况下,这种解析将需要,但是您很幸运:在这种情况下,有一个非常简单的解决方案。与其尝试将它们全部捕获为有效输入,只需解析一个,然后将其余的作为$($ tt)*

macro_rules! script {
    ($val:literal ! $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("{}!", $val))
    };
    ($cmd:ident ! $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("{}!", stringify!($cmd)))
    };
    (!$val:literal $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("!{}", $val))
    };
    (!$cmd:ident $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("!{}", stringify!($cmd)))
    };
    () => {
        Script::new(String::new())
    };
}

至于扭转订单,我建议您不要打扰。即使是这样 - 您只需要附加到向量的末尾,然后 recters() IT。但是,为了娱乐,可能是可能的,但需要推下堆积。这是一个示例:

macro_rules! script_impl {
    {
        [ $($parsed:tt)* ]
        $val:literal !
        $($rest:tt)*
    } => {
        script_impl! {
            [
                // The parentheses are important for it to be one `tt`.
                // I choose parentheses to because they're still valid
                // expression producing `&str` (although braces will
                // also do, but brackets not).
                ( concat!(stringify!($val), "!") )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $($parsed:tt)* ]
        ! $val:literal
        $($rest:tt)*
    } => {
        script_impl! {
            [
                ( concat!("!", stringify!($val)) )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $($parsed:tt)* ]
        $cmd:ident !
        $($rest:tt)*
    } => {
        script_impl! {
            [
                ( concat!(stringify!($cmd), "!") )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $($parsed:tt)* ]
        ! $cmd:ident
        $($rest:tt)*
    } => {
        script_impl! {
            [
                ( concat!("!", stringify!($cmd)) )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $first_parsed:tt $($rest_parsed:tt)* ]
        // Finished parsing
    } => {
        Script::new($first_parsed)
            $( .append($rest_parsed) )*
    };
}
macro_rules! script {
    ( $($t:tt)* ) => {
        script_impl! {
            [ ]
            $($t)*
        }
    }
}

In many case such parsing will require push-down accumulation, but you are lucky: there is a very simple solution in this case. Instead of trying to capture them all as valid input, just parse one and forward the rest as $($tt)*:

macro_rules! script {
    ($val:literal ! $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("{}!", $val))
    };
    ($cmd:ident ! $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("{}!", stringify!($cmd)))
    };
    (!$val:literal $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("!{}", $val))
    };
    (!$cmd:ident $($vals:tt)*) => {
        script!($($vals)*).prepend(format!("!{}", stringify!($cmd)))
    };
    () => {
        Script::new(String::new())
    };
}

Playground.

As for reversing the order, I'd recommend you to not bother. This can be very efficient even as is - you just need to append to the end of the vector then reverse() it. However, for the sake of fun, it is possible but requires push-down accumulation. Here's an example:

macro_rules! script_impl {
    {
        [ $($parsed:tt)* ]
        $val:literal !
        $($rest:tt)*
    } => {
        script_impl! {
            [
                // The parentheses are important for it to be one `tt`.
                // I choose parentheses to because they're still valid
                // expression producing `&str` (although braces will
                // also do, but brackets not).
                ( concat!(stringify!($val), "!") )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $($parsed:tt)* ]
        ! $val:literal
        $($rest:tt)*
    } => {
        script_impl! {
            [
                ( concat!("!", stringify!($val)) )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $($parsed:tt)* ]
        $cmd:ident !
        $($rest:tt)*
    } => {
        script_impl! {
            [
                ( concat!(stringify!($cmd), "!") )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $($parsed:tt)* ]
        ! $cmd:ident
        $($rest:tt)*
    } => {
        script_impl! {
            [
                ( concat!("!", stringify!($cmd)) )
                $($parsed)*
            ]
            $($rest)*
        }
    };
    {
        [ $first_parsed:tt $($rest_parsed:tt)* ]
        // Finished parsing
    } => {
        Script::new($first_parsed)
            $( .append($rest_parsed) )*
    };
}
macro_rules! script {
    ( $($t:tt)* ) => {
        script_impl! {
            [ ]
            $($t)*
        }
    }
}

Playground.

坚持写一个递归的锈蚀声明性宏观宏观

≈。彩虹 2025-02-18 02:08:29

您可以在请求参数中从前端发送客户端ID。示例:http:yourdomain:端口/路线/:

后端中的食谱您可以这样处理:

router.get('/',async(req,res)=>{
    const recipefound=await Recipe.find({materials: req.params.recipeID})

    res.send(recipefound);
});

You can send the client ID from front end in request params. Example: http:yourdomain:port/route/:recipeID

In backend you can handle like this:

router.get('/',async(req,res)=>{
    const recipefound=await Recipe.find({materials: req.params.recipeID})

    res.send(recipefound);
});

如何从客户那里获取ID?(Express and Mongoose)

≈。彩虹 2025-02-17 17:23:52

这条线

b = p;

有几个问题。首先,数组表达可能不是=运算符的目标。您不能在单个操作中分配整个数组,例如 1

其次,类型不匹配; p具有类型int(*)[3],而b具有类型int [3]。阵列不是指针-Array 表达式在大多数情况下对指针表达式的“衰减”,但是在这种情况下,即使指示器也将是不兼容的类型(b都会衰减到表达式类型int *,而不是int( *)[3])。

不,将一个数组的内容复制到另一个数组的唯一方法是使用库函数,例如memcpy或使用循环单独分配每个元素:

for ( size_t i = 0; i < 3; i++ )
  b[i] = (*p)[i]; // or b[i] = a[i]

就是这样。


  1. 初始化与分配不同。

The line

b = p;

has a couple of problems. First of all, array expressions may not be the target of the = operator; you can't assign an entire array in a single operation like that1.

Secondly, the types don't match; p has type int (*)[3], while b has type int [3]. Arrays are not pointers - array expressions "decay" to pointer expressions under most circumstances, but in this case even the pointers would be of incompatible types (b would decay to an expression of type int *, not int (*)[3]).

No, the only ways to copy the contents of one array to the other are to use library functions like memcpy or to use a loop to assign each element individually:

for ( size_t i = 0; i < 3; i++ )
  b[i] = (*p)[i]; // or b[i] = a[i]

That's it.


  1. Initialization is different from assignment.

如何将指针分配给数组,新数组?

≈。彩虹 2025-02-17 13:51:32

您需要实施 asycnvalidator

如果您愿意,您也可以在同一验证器中包含验证器。

private validateEmail(email: string): Observable<ValidationErrors | null> {
    //required
    if (!email) return of({ required: true });

    //email regExpr
    const EMAIL_REGEXP =
      /^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;

    if (!EMAIL_REGEXP.test(email)) return of({ email: true });

    return of(email).pipe(
      debounceTime(500),
      distinctUntilChanged(),
      delay(500),
      map((email) => {
        //check if exist
        return emailsYetGet.find((x) => x == email)
          ? {
              isTaken: 'Email exists already.',
            }
          : null;
      })
    );
  }

​stackblitz

注意:请记住,请记住您的指示在模块的声明中,您使用它的组件在哪里,并检查您的api

note2:regexpr我得到了

You need implements AsycnValidator not Validator

If you want, you can also include in the same validator a validator.required and a validator.email

private validateEmail(email: string): Observable<ValidationErrors | null> {
    //required
    if (!email) return of({ required: true });

    //email regExpr
    const EMAIL_REGEXP =
      /^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;

    if (!EMAIL_REGEXP.test(email)) return of({ email: true });

    return of(email).pipe(
      debounceTime(500),
      distinctUntilChanged(),
      delay(500),
      map((email) => {
        //check if exist
        return emailsYetGet.find((x) => x == email)
          ? {
              isTaken: 'Email exists already.',
            }
          : null;
      })
    );
  }

a stackblitz

NOTE: Remember include your directive in declarations of the modules where is the components in witch you use it and check you API

NOTE2: the REGEXPR I get it form the Angular's github about validators

如何使用异步呼叫使用验证器指令

≈。彩虹 2025-02-17 11:29:27

您已经对评论中的错误有一个答案,但是我将提出一种更简单的方法。

您可以直接在列表元素上迭代,这通常是建议的,并使代码更简单:

fruits = ["Apple", "Mango", "Guava", "Kiwi","Melon"]

for fruit in fruits:
    if fruit == "Guava" or fruit == "Mango":
        print(fruit)

You already have an answer about the error in the comments, but I'll propose a simpler approach.

You can iterate over the list elements directly, which is usually recommended and makes the code simpler:

fruits = ["Apple", "Mango", "Guava", "Kiwi","Melon"]

for fruit in fruits:
    if fruit == "Guava" or fruit == "Mango":
        print(fruit)

我是新手Python,并且在运行代码时,我会遇到一个错误:对象不是可呼叫的“。”有人可以帮我吗

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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