没︽人懂的悲伤

文章 评论 浏览 29

没︽人懂的悲伤 2025-02-21 01:06:07

有几种分类数组的方法。我会提到一些完成该任务的方法。所有方法,我将提供一个被称为“ $数字”的整数数组。

$number = array(8,9,3,4,0,1,2);

这是创建数组的正常方法。假设我想按升序排序该数组。为此,可以使用“ sort()”方法。

<?php

    $number = array(8,9,3,4,0,1,2);
    sort($number);

   foreach ($number as $value) {
       echo $value."  ";
   }
?>

现在考虑一下输出,

”在此处输入图像说明“

您可以看到打印的号码数组已排序。如果您想将该数字数组分类为降序,则可以将“ rsort()”方法用于该任务。

<?php

     $number = array(8,9,3,4,0,1,2);
     rsort($number);

     foreach ($number as $value) {
        echo $value."  ";
     }
?>

考虑输出..

“在此处输入图像描述”

现在以降序排序数组。 Array.i将给出一个关联数组(关联数组意味着,每个索引都有唯一的钥匙值的数组。)这样,

$number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);

现在,我想按照其值按升序排列此数组。可以用来使用。

<?php

   $number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);
   asort($number);

   foreach ($number as $value) {
      echo $value."  ";
    }
?>

如果按其价值对降序进行排序,则可以使用“ Arsort()”方法。
假设您想根据数组的关键值对该数组进行排序。在此中,可以使用“ ksort()”方法。

<?php

     $number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);
     ksort($number);

     foreach ($number as $value) {
         echo $value."  ";
     }
?>

现在考虑输出。

现在按其关键值进行排序。如果您想根据降序排序数组可以使用它们的关键值“ krsort()”方法。

<?php

    $number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);
    krsort($number);

    foreach ($number as $value) {
       echo $value."  ";
    }
?>

现在,关联阵列按降序按关键值进行排序。查看输出。

这些是在php.i中以升序或降序排列数组的某些方法希望您能得到一个主意。谢谢!

There are several ways to sort an array.I will mention some methods for doing that task.fist of all , I will give an integer array which is called as '$numbers'.

$number = array(8,9,3,4,0,1,2);

This is the normal way to creating an array. Suppose that , I want to sort that array in ascending order.For that, 'sort()' method can be used.

<?php

    $number = array(8,9,3,4,0,1,2);
    sort($number);

   foreach ($number as $value) {
       echo $value."  ";
   }
?>

Now consider the output of that,

enter image description here

You can see printed number array is sorted. If you want to that number array to be sort is descending order, 'rsort()' method can be use for that task.

<?php

     $number = array(8,9,3,4,0,1,2);
     rsort($number);

     foreach ($number as $value) {
        echo $value."  ";
     }
?>

consider the output..

enter image description here

Now array is sorted in descending order.Ok, Let's consider an associative array.I will give an associative array(Associative array means that, An array whose each index has unique key value.) like this,

$number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);

So ,Now I want to sort this array in ascending order according their value.'asort()' method can be used for that.

<?php

   $number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);
   asort($number);

   foreach ($number as $value) {
      echo $value."  ";
    }
?>

If sorting descending order according their value,'arsort()' method can be used.
Suppose that you want to sort that array according their key value. In this , 'ksort()' method can be use.

<?php

     $number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);
     ksort($number);

     foreach ($number as $value) {
         echo $value."  ";
     }
?>

Now consider the output.
enter image description here

Now array is sorted according their key value.If You want to sort the array in descending order according their key value,'krsort()' method can be used.

<?php

    $number = array('eight'=>8,'nine'=>9,'three'=>3,'fore'=>4,'zero'=>0,'one'=>1,'two'=>2);
    krsort($number);

    foreach ($number as $value) {
       echo $value."  ";
    }
?>

Now associative array is sorted in descending order according their key value.Look at the output.
enter image description here

These are the some methods for sorting an array in ascending or descending order in php.I hope to you could get an idea.Thank you!

如何在PHP中对数组和数据进行排序?

没︽人懂的悲伤 2025-02-20 17:55:10

由于HTML代码中的错字,我遇到了类似的问题:

<template>
...
<template>

您可能会看到闭合模板标签中缺少斜线,因此适当的代码应该是:

<template>
...
</template>

在这种情况下,错误是错误的误导性。 ,您可能会认为,涉及脚本初始化中某种种族条件,但它更加简单。

I faced a similar issue because of a typo in html code:

<template>
...
<template>

As you may see the slash is missing in closing template tag, so the proper code should be:

<template>
...
</template>

In this specific case the error is way too misleading, as you may think that some sort of race-condition in script init is involved, but it is way more straightforward.

使用脚本标签时,Alpine.data()中的键是未定义的

没︽人懂的悲伤 2025-02-20 02:10:54

事实证明,即使不需要非零工人的数据, MULTI_WORKER_MODER.SAVE() 必须在所有工人中调用

在这里,完整的工作代码(请注意最后2行,添加):

import json
import os
import tensorflow as tf
import numpy as np


def mnist_dataset(batch_size):
    (x_train, y_train), _ = tf.keras.datasets.mnist.load_data()
    # The `x` arrays are in uint8 and have values in the [0, 255] range.
    # You need to convert them to float32 with values in the [0, 1] range.
    x_train = x_train / np.float32(255)
    y_train = y_train.astype(np.int64)
    train_dataset = tf.data.Dataset.from_tensor_slices(
        (x_train, y_train)).shuffle(60000).repeat().batch(batch_size)
    return train_dataset

def build_and_compile_cnn_model():
    model = tf.keras.Sequential([
        tf.keras.layers.InputLayer(input_shape=(28, 28)),
        tf.keras.layers.Reshape(target_shape=(28, 28, 1)),
        tf.keras.layers.Conv2D(32, 3, activation='relu'),
        tf.keras.layers.Flatten(),
        tf.keras.layers.Dense(128, activation='relu'),
        tf.keras.layers.Dense(10)
    ])
    model.compile(
        loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
        optimizer=tf.keras.optimizers.SGD(learning_rate=0.001),
        metrics=['accuracy'])
    return model


tf_config = json.loads(os.environ['TF_CONFIG'])
strategy = tf.distribute.MultiWorkerMirroredStrategy()

PER_WORKER_BATCH_SIZE = 64
global_batch_size = PER_WORKER_BATCH_SIZE * len(tf_config['cluster']['worker'])

with strategy.scope():
    options = tf.data.Options()
    options.experimental_distribute.auto_shard_policy = tf.data.experimental.AutoShardPolicy.DATA
    multi_worker_dataset = mnist_dataset(global_batch_size)
    multi_worker_dataset = multi_worker_dataset.with_options(options)
    # Model building/compiling need to be within `strategy.scope()`.
    multi_worker_model = build_and_compile_cnn_model()

#multi_worker_model.fit(multi_worker_dataset, epochs=3, steps_per_epoch=70)
multi_worker_model.fit(multi_worker_dataset, epochs=3, steps_per_epoch=70)

if tf_config['task']['index'] == 0:
    multi_worker_model.save(".")
else:
    multi_worker_model.save(f"./workertmp{tf_config['task']['index']}")

It turns out that multi_worker_model.save() must be called in all workers even if the data of the non-zero workers is not required.

Here the full working code (notice the last 2 lines, which were added):

import json
import os
import tensorflow as tf
import numpy as np


def mnist_dataset(batch_size):
    (x_train, y_train), _ = tf.keras.datasets.mnist.load_data()
    # The `x` arrays are in uint8 and have values in the [0, 255] range.
    # You need to convert them to float32 with values in the [0, 1] range.
    x_train = x_train / np.float32(255)
    y_train = y_train.astype(np.int64)
    train_dataset = tf.data.Dataset.from_tensor_slices(
        (x_train, y_train)).shuffle(60000).repeat().batch(batch_size)
    return train_dataset

def build_and_compile_cnn_model():
    model = tf.keras.Sequential([
        tf.keras.layers.InputLayer(input_shape=(28, 28)),
        tf.keras.layers.Reshape(target_shape=(28, 28, 1)),
        tf.keras.layers.Conv2D(32, 3, activation='relu'),
        tf.keras.layers.Flatten(),
        tf.keras.layers.Dense(128, activation='relu'),
        tf.keras.layers.Dense(10)
    ])
    model.compile(
        loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
        optimizer=tf.keras.optimizers.SGD(learning_rate=0.001),
        metrics=['accuracy'])
    return model


tf_config = json.loads(os.environ['TF_CONFIG'])
strategy = tf.distribute.MultiWorkerMirroredStrategy()

PER_WORKER_BATCH_SIZE = 64
global_batch_size = PER_WORKER_BATCH_SIZE * len(tf_config['cluster']['worker'])

with strategy.scope():
    options = tf.data.Options()
    options.experimental_distribute.auto_shard_policy = tf.data.experimental.AutoShardPolicy.DATA
    multi_worker_dataset = mnist_dataset(global_batch_size)
    multi_worker_dataset = multi_worker_dataset.with_options(options)
    # Model building/compiling need to be within `strategy.scope()`.
    multi_worker_model = build_and_compile_cnn_model()

#multi_worker_model.fit(multi_worker_dataset, epochs=3, steps_per_epoch=70)
multi_worker_model.fit(multi_worker_dataset, epochs=3, steps_per_epoch=70)

if tf_config['task']['index'] == 0:
    multi_worker_model.save(".")
else:
    multi_worker_model.save(f"./workertmp{tf_config['task']['index']}")

TensorFlow不可用:从 /job报告的错误:工作 /任务:2

没︽人懂的悲伤 2025-02-20 00:12:48

WordPress主题函数中的重定向有一个自定义条件。PHP引起重定向。删除这些代码就像魅力一样

There was a custom condition for the redirect in the WordPress theme function.php which was causing redirects. Removed those codes worked like a charm

err_too_many_redirects wordpress中的hompage

没︽人懂的悲伤 2025-02-19 20:28:30

tl; dr:只需避免使用操作员,但是任务流动api,一切都更简单。传统运营商非常僵硬,很难与IMO打交道。

如果您在Google中搜索从操作员到另一个操作员或父级DAG的将结果传递到Sub Dag,通常您会发现一个Jinja2模板可以从XCOM中提取结果,但是许多人发现它不起作用。结果是因为并非所有字段都会被插值,而是在操作员中注册的那些字段 template_fields 将被渲染。

https://airflow.apache.org/docs/apache-airflow/stable/concepts/operators.html#jinja-templating

您也可以使用嵌套字段的Jinja模板,只要将这些嵌套字段标记为它们所属的结构中的模板:在Template_fields属性中注册的字段将提交给Template替代


解决方案就是运行操作员并将其传递给任务流的装饰。使用 @task 函数,并通过 .extand 从操作员展开结果。在实际运行中感到非常清楚吗?是的,只有在需要时仅使用TaskFlow API和传统运算符。

https://airflow.apache.org/docs/apache-airflow/2.3.0/coneptes/dynamic-task-mapping.html#putting-it-it-it-all-all-together

    get_all_ddl_fixing_sqls = BigQueryGetDataOperator(
        task_id='get_all_ddl_fixing_sqls',
        dataset_id='my_dataset',
        table_id='my_ddl_fixing_table',
        selected_fields='ddl',
        max_results=9999999, # Default is 100, maybe -1 equals to unlimited, I have not tried
        dag=dag
    )

    # Workers might time out occasionally, remember to retry
    @task(retries=5)
    def fix_bq_schema_by_prepared_ddl(ddl_fixing_sql):
        BigQueryHook(use_legacy_sql=False).insert_job(
            location='asia-east2',
            configuration={
                'query': {
                    'query': ddl_fixing_sql[0],
                    'projectId': project_id,
                    'datasetId': dataset_id,
                    'useLegacySql': False,
                },
            },
        )

    fix_bq_schema_by_prepared_ddl = fix_bq_schema_by_prepared_ddl.partial().expand(
        ddl_fixing_sql=XComArg(get_all_ddl_fixing_sqls)
    )

TL;DR: Just avoid to use operators but TaskFlow API, everything is simpler. Tradition operators are pretty rigid and hard to deal with IMO.

If you search in Google for passing result from operator to another operator or parent DAG to sub DAG, usually you will find a Jinja2 template to pull result from Xcom, yet many people found it is not working. The result is because not all fields will be interpolated but those registered in Operator template_fields will be rendered.

https://airflow.apache.org/docs/apache-airflow/stable/concepts/operators.html#jinja-templating

You can also use Jinja templating with nested fields, as long as these nested fields are marked as templated in the structure they belong to: fields registered in template_fields property will be submitted to template substitution


The solution is to run the operator and pass to TaskFlow decorated function with @task and expand result from operator by .expand. Feels a lot clear on what is actually running? Yeah, just use TaskFlow API mainly and traditional operators only if needed.

https://airflow.apache.org/docs/apache-airflow/2.3.0/concepts/dynamic-task-mapping.html#putting-it-all-together

    get_all_ddl_fixing_sqls = BigQueryGetDataOperator(
        task_id='get_all_ddl_fixing_sqls',
        dataset_id='my_dataset',
        table_id='my_ddl_fixing_table',
        selected_fields='ddl',
        max_results=9999999, # Default is 100, maybe -1 equals to unlimited, I have not tried
        dag=dag
    )

    # Workers might time out occasionally, remember to retry
    @task(retries=5)
    def fix_bq_schema_by_prepared_ddl(ddl_fixing_sql):
        BigQueryHook(use_legacy_sql=False).insert_job(
            location='asia-east2',
            configuration={
                'query': {
                    'query': ddl_fixing_sql[0],
                    'projectId': project_id,
                    'datasetId': dataset_id,
                    'useLegacySql': False,
                },
            },
        )

    fix_bq_schema_by_prepared_ddl = fix_bq_schema_by_prepared_ddl.partial().expand(
        ddl_fixing_sql=XComArg(get_all_ddl_fixing_sqls)
    )

如何根据Apache气流中的另一个运算符重新列出的数组结果正确添加运算符?

没︽人懂的悲伤 2025-02-19 12:29:34

检查这个。我希望这能解决您的问题。

 body: ListView.builder(
    itemCount: cities.length,
    itemBuilder: (context, index) {
    //..................................................ListTile
      return ListTile(
        leading: CircleAvatar(
          child: Text(cities[index].cityName[index][0]),
        ),
        title: Text(cities[index].cityName),
        subtitle: Text(cities[index].countryName),
        trailing: Text("\$" + prices[index]),
      );
    },
  ),

Check this one. I hope this will solve your problem.

 body: ListView.builder(
    itemCount: cities.length,
    itemBuilder: (context, index) {
    //..................................................ListTile
      return ListTile(
        leading: CircleAvatar(
          child: Text(cities[index].cityName[index][0]),
        ),
        title: Text(cities[index].cityName),
        subtitle: Text(cities[index].countryName),
        trailing: Text("\
quot; + prices[index]),
      );
    },
  ),

如何在listView.builder中使用小部件列表?

没︽人懂的悲伤 2025-02-19 08:08:50

只要它们都具有相同的格式(例如,CSV文件中的相同列),Amazon Athena可以在给定的Amazon S3路径中的多个对象上运行查询。

它可以通过使用创建表作为命令和 location 参数来存储新的外部表格,其位置指向S3存储桶。

可以通过设置输出存储桶的数量来控制输出文件的大小(不是与S3存储桶相同)。

请参阅:

Amazon Athena can run a query across multiple objects in a given Amazon S3 path, as long as they all have the same format (eg same columns in a CSV file).

It can store the result in a new External Table, with a location pointing to an S3 bucket, by using a CREATE TABLE AS command and a LOCATION parameter.

The size of the output files can be controlled by setting the number of output buckets (which is not the same as an S3 bucket).

See:

将S3文件合并到多个1GB S3文件中

没︽人懂的悲伤 2025-02-18 09:09:47

简短答案是:将numpy阵列切成滤波器值&lt; = 40%。例如,如果 a 是一个1D numpy数组:

a[a <= 40]

以下示例提供了更长的答案,该示例显示了:

  • 的正态分布随机数据(因为提供的数据集很小)
  • 执行计算 在Numpy阵列上
  • 切片阵列以返回值&lt; = 40%
  • 使用 - 仅API。

示例代码:

import numpy as np
import plotly.io as pio

# Generate random dataset (for demo only).
np.random.seed(1)
X = np.random.normal(0, 1, 10000)

# Calculate the cumulative frequency.
X_ = np.cumsum(X)*100/X.sum()
data = X_[X_ <= 40]

# Plot the histogram.
pio.show({'data': {'x': data, 
                   'type': 'histogram', 
                   'marker': {'line': {'width': 0.5}}},
          'layout': {'title': 'Cumulative Frequency Demo'}})

输出:

“在此处输入图像描述”

The short answer is: Slice the numpy array to filter values <= 40%. For example, if a is a 1D numpy array:

a[a <= 40]

A longer answer is provided by the example below, which shows:

  • A generation of normally distributed random data (as the provided dataset is very small)
  • Performing your calculation on the numpy array
  • Slicing the array to return values which are <= 40%
  • Plotting the results using the Plotly library - API only.

Example code:

import numpy as np
import plotly.io as pio

# Generate random dataset (for demo only).
np.random.seed(1)
X = np.random.normal(0, 1, 10000)

# Calculate the cumulative frequency.
X_ = np.cumsum(X)*100/X.sum()
data = X_[X_ <= 40]

# Plot the histogram.
pio.show({'data': {'x': data, 
                   'type': 'histogram', 
                   'marker': {'line': {'width': 0.5}}},
          'layout': {'title': 'Cumulative Frequency Demo'}})

Output:

enter image description here

Python:如何绘制条件累积频率直方图?

没︽人懂的悲伤 2025-02-18 03:02:19

您可以使用一般函数来基于基于垂直于向量的垂直。然后,您只需将正确长度的垂直向量添加到前两个顶点的中点即可。如注释中指出的那样,当尺寸的数量大于2以上时,有无限数量的顶点可以解决此问题。此方法简单地识别一种易于计算的方法。

def magnitude(v):
    """ Return the magnitude of a vector. See https://stackoverflow.com/a/9184560/567595 """
    return np.sqrt(v.dot(v))

def perpendicular(u):
    """ Return a vector perpendicular to vector v, of magnitude 1.
        Based on https://math.stackexchange.com/a/3175858
    """
    r = np.zeros(u.shape)
    zeros, = np.where(u == 0)
    if zeros.size > 0:  # If any u[i] is zero, return standard vector e_i
        r[zeros[0]] = 1
    else:               # Otherwise return u[1]e_0 - u[0]e_1
        m = magnitude(u[:2])
        r[:2] = u[1] / m, -u[0] / m
    return r 

def third_vertex_equilateral(A, B):
    """ Find a third vertex of an equilateral triangle with vertices A and B, in N dimensions """
    side = A - B
    midpoint = (A + B) / 2
    bisector = perpendicular(side) * np.sqrt(.75) * magnitude(side)
    return midpoint + bisector

N = 5
A = np.random.normal(size=N)
B = np.random.normal(size=N)
C = third_vertex_equilateral(A, B)
np.isclose(magnitude(A - B), magnitude(A - C)) # True
np.isclose(magnitude(A - B), magnitude(B - C)) # True

请注意,当更简洁地写入时,该功能与问题中的功能非常相似:

def third_vertex_equilateral(A, B):
    """ Find a third vertex of an equilateral triangle with vertices A and B, in N dimensions """
    return (A + B + np.sqrt(3) * perpendicular(A - B) * magnitude(A - B)) / 2

You can use a general function to find a perpendicular to a vector based on this method. Then you just add a perpendicular vector of the right length to the midpoint of the first two vertices. As noted in comments, there are an infinite number of vertices that would solve this when the number of dimensions is more than 2. This method simply identifies one that is easy to calculate.

def magnitude(v):
    """ Return the magnitude of a vector. See https://stackoverflow.com/a/9184560/567595 """
    return np.sqrt(v.dot(v))

def perpendicular(u):
    """ Return a vector perpendicular to vector v, of magnitude 1.
        Based on https://math.stackexchange.com/a/3175858
    """
    r = np.zeros(u.shape)
    zeros, = np.where(u == 0)
    if zeros.size > 0:  # If any u[i] is zero, return standard vector e_i
        r[zeros[0]] = 1
    else:               # Otherwise return u[1]e_0 - u[0]e_1
        m = magnitude(u[:2])
        r[:2] = u[1] / m, -u[0] / m
    return r 

def third_vertex_equilateral(A, B):
    """ Find a third vertex of an equilateral triangle with vertices A and B, in N dimensions """
    side = A - B
    midpoint = (A + B) / 2
    bisector = perpendicular(side) * np.sqrt(.75) * magnitude(side)
    return midpoint + bisector

N = 5
A = np.random.normal(size=N)
B = np.random.normal(size=N)
C = third_vertex_equilateral(A, B)
np.isclose(magnitude(A - B), magnitude(A - C)) # True
np.isclose(magnitude(A - B), magnitude(B - C)) # True

Note that when written more succinctly, the function is quite similar to the one in the question:

def third_vertex_equilateral(A, B):
    """ Find a third vertex of an equilateral triangle with vertices A and B, in N dimensions """
    return (A + B + np.sqrt(3) * perpendicular(A - B) * magnitude(A - B)) / 2

在python中找到两个N维垂直的等边训练的第三个顶点

没︽人懂的悲伤 2025-02-17 22:40:26

首先,您的 index.js doutes.js 文件很好,现在您只需要正确发送请求,请参阅req.params不同,并且req.query是不同的

第一个方法 在Postman中使用(查询)

http://localhost:3000/api/v1/users?id=120622

您的索引。

app.use('/api/v1/users', userRouter);

在路由器文件中。

router.get("/", getUserDataById);

您是如何获得该ID的?

let id = req.query.id;

使用(params)的第二种方式 - 仔细查看Postman URL,然后

在Postman:

http://localhost:3000/api/v1/users/120622

您的索引中的路线上查看。

app.use('/api/v1/users', userRouter);

在路由器文件中。

router.get("/:id", getUserDataById);

您是如何获得该ID的?

let id = req.params.id;

这是您可以获得ID的双向,如果您还有其他问题,请告诉我,我会尽力更加清晰地澄清您的观点。

Firstly your index.js and routes.js file is fine now you just need to send request correctly see the req.params is different and the req.query is different

First Way with (Query)

In postman:

http://localhost:3000/api/v1/users?id=120622

Your Index.

app.use('/api/v1/users', userRouter);

In Router file.

router.get("/", getUserDataById);

How did you get that id;

let id = req.query.id;

Second Way with (Params) - Look at the postman URL carefully and at Route

In postman:

http://localhost:3000/api/v1/users/120622

Your Index.

app.use('/api/v1/users', userRouter);

In Router file.

router.get("/:id", getUserDataById);

How did you get that id;

let id = req.params.id;

This is the two-way you can get your id, Let me know if you have any more questions and I'll try to clarify your points with more clarity.

无法在localhost中使用ExpressJS API使用查询参数

没︽人懂的悲伤 2025-02-17 20:28:14

您可以进行多个,但会影响一个上下文,因此,如果您需要多个功能,则可以在一个上下文中实现它们,并通过破坏

&lt; democontext.provider value = {{function1,function2 function3}}&gt;&lt;&lt; /democontext.provider>

使用

const {function1}= useContext(DemoContext)

You can make multiple but it will affect one context so if you need multiple functionalities you can implement them in one context and use them by destructuring

<DemoContext.Provider value={{function1, function2 function3}}></DemoContext.Provider>

use

const {function1}= useContext(DemoContext)

Reactjs“上下文”可以有多个提供商吗?

没︽人懂的悲伤 2025-02-17 19:18:07

修改点:

  • 在您的脚本中, Sheet1 不是声明。
  • getActivecell exepl1.getActivecell.getValue()不作为方法运行。
  • 我以为 nameVal =='alpha'|| nameVal =='beta'可以由 incold 写成。

当这些要点反映在您的脚本中时,如下所示。

修改后的脚本:

function onEdit(e) {
  var range = e.range;
  var sheet1 = range.getSheet();
  if (range.getA1Notation() === 'A2') {
    var active = ['Alpha', 'Beta'].includes(range.getValue()) ? "D7" : "F1";
    sheet1.getRange(active).activate();
  }
}
  • 在此修改后的脚本中,当将“ alpha”或“ beta”的值放在单元格“ A2”时,激活了单元格“ D7”。当将“ alpha”和“ beta”除外的值放在单元格“ A2”时,“ F1”被激活。

注意:

  • 此脚本由ONEDIT简单触发器自动运行。因此,当您直接使用脚本编辑器直接运行此脚本时,会发生错误。请注意。

参考:

Modification points:

  • In your script, sheet1 is not declaread.
  • getActiveCell of sheet1.getActiveCell.getValue() is not run as the method.
  • I thought that nameval == 'Alpha' || nameval == 'Beta' might be written by includes.

When these points are reflected in your script, it becomes as follows.

Modified script:

function onEdit(e) {
  var range = e.range;
  var sheet1 = range.getSheet();
  if (range.getA1Notation() === 'A2') {
    var active = ['Alpha', 'Beta'].includes(range.getValue()) ? "D7" : "F1";
    sheet1.getRange(active).activate();
  }
}
  • In this modified script, when a value of 'Alpha' or 'Beta' is put to the cell "A2", the cell "D7" is activated. When a value except for 'Alpha' and 'Beta' is put to the cell "A2", the cell "F1" is activated.

Note:

  • This script is automatically run by the OnEdit simple trigger. So, when you directly run this script with the script editor, an error occurs. Please be careful about this.

References:

如何根据编辑的内容来获得不同的单元格以激活?

没︽人懂的悲伤 2025-02-17 06:38:22

您需要在代码沙箱中安装正确的依赖项。

相反,如果这是任何项目或部分项目,我建议您在本地环境中工作,并通过关注这些
步骤。

其次,如果这是出于插图或学习目的,则可以从中使用 “>在这里

You need to install the correct dependency in the code sandbox.

Rather, if this is any project or part of it, I would suggest you work in the local environment and install the npm package by following these
steps.

Secondly, if this is for illustration or learning purposes then you can use the tailwind-element snippet from here.

为什么我的钟声不使用React和Tailwind CSS工作?

没︽人懂的悲伤 2025-02-17 05:20:23

Python解释器引起以下问题,因为您在执行程序时要调用的错误python版本是F字符串是Python 3的一部分,而不是Python 2的一部分。应该工作。要解决此问题,请将Python解释器从2更改为3。&nbsp;

Python Interpreter causes the following issue because of the wrong python version you calling when executing the program as f strings are part of python 3 and not python 2. You could do this python3 filename.py, it should work. To fix this issue, change the python interpreter from 2 to 3. 

f链条给出语法?

没︽人懂的悲伤 2025-02-16 23:09:58

这样的东西会切换到不同的选项卡(x为迭代器)。 0将是第一个选项卡,然后是1,2。

driver.switch_to.window(驱动程序

Something like this would switch to different tabs (x being the iterator). 0 Would be the first tab and then 1,2 so on.

driver.switch_to.window(driver.window_handles[x])

使用Python拍摄多个开放式浏览器选项卡的屏幕截图

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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