雄赳赳气昂昂

文章 评论 浏览 29

雄赳赳气昂昂 2025-02-03 22:19:34

您可以通过简单地将值分配给键,例如键已经存在,则可以将值添加到字典

output_dic['Max Volume (Date)'] = [0, 1, 2]

中要替换从.txt文件读取的值,用字典中已分配的值读取:

output_dic = {'Max Volume (Date)': ["", "", ""],
                'Min Value (Date)' : ["" , "", ""],
                'Lowest Open (Date)' : ["", "", ""] ,
                'Highest Close (Date)' : ["", "", ""],
                'Highest Monthly Average (Months)' : ["", "" , ""],
                'Lowest Monthly Average (Months)' : ["", "", ""],
                'Annual Average (Months)' : ["", "", ""]}

keys_list = ['Max Volume (Date)', 'Min Value (Date)', 'Lowest Open (Date)', 'Highest Close (Date)', 'Highest Monthly Average (Months)', 'Lowest Monthly Average (Months)', 'Annual Average (Months)']

input_file_address = 'E://file_name.txt'

with open(input_file_address, 'r') as input_file:
    index = 0
    for line in input_file:
        line_stripped = line.strip() # .txt files' lines usually end with \n and they could also have whitespace at the beginning by mistake, this line removes these issues
        
        if line_stripped == '': # if the line is empty, move to the next line
            continue
        
        line_splitted = line_stripped.split(' ') # If the values are separated by whitespace, this line would convert a string of for example 'a b c' to a list of ['a', 'b', 'c'] 
        
        key = keys_list[index]

        output_dic[key] = line_splitted

        index += 1

print(output_dic)

假设.txt文件的格式如下:

value_1,value_2,value_3 ..........................................................................................................................................
..........................................

每行对应于其他参数,例如“ min
价值”等等。

最后,我想提出一个建议:
我认为.txt对于这些类型的操作不是合适的文件格式,我个人更喜欢.csv,因为格式是无关的,因此更容易解析,这与.txt文件不同,任何人都可以以任何格式编写任何内容。

You can add values to a dictionary by simply assigning the values to a keys, if for example a key already exists, then the new value would replace the old one, for example:

output_dic['Max Volume (Date)'] = [0, 1, 2]

Just to be complete I would write a sample code snippet on how to replace values read from a .txt file with values already assigned in a dictionary:

output_dic = {'Max Volume (Date)': ["", "", ""],
                'Min Value (Date)' : ["" , "", ""],
                'Lowest Open (Date)' : ["", "", ""] ,
                'Highest Close (Date)' : ["", "", ""],
                'Highest Monthly Average (Months)' : ["", "" , ""],
                'Lowest Monthly Average (Months)' : ["", "", ""],
                'Annual Average (Months)' : ["", "", ""]}

keys_list = ['Max Volume (Date)', 'Min Value (Date)', 'Lowest Open (Date)', 'Highest Close (Date)', 'Highest Monthly Average (Months)', 'Lowest Monthly Average (Months)', 'Annual Average (Months)']

input_file_address = 'E://file_name.txt'

with open(input_file_address, 'r') as input_file:
    index = 0
    for line in input_file:
        line_stripped = line.strip() # .txt files' lines usually end with \n and they could also have whitespace at the beginning by mistake, this line removes these issues
        
        if line_stripped == '': # if the line is empty, move to the next line
            continue
        
        line_splitted = line_stripped.split(' ') # If the values are separated by whitespace, this line would convert a string of for example 'a b c' to a list of ['a', 'b', 'c'] 
        
        key = keys_list[index]

        output_dic[key] = line_splitted

        index += 1

print(output_dic)

Assuming the .txt file is formatted as below:

value_1, value_2, value_3 .........................
.........................

where each line corresponds to a different parameter for example "Min
Value" and so on.

And finally I would like to make a recommandations:
I think .txt is not a suitable file format for these types of operations, I personally prefer .csv, it's easier to parse since the formatting is unversal, unlike a .txt file where anyone can write anything in any format.

在创建的字典中的空键中添加值

雄赳赳气昂昂 2025-02-03 20:46:35

我会建议您阅读 pathlib.path.path

示例:

from pathlib import Path

BASE_PATH = Path(...)

RECORDS_PATH = BASE_PATH / "records"

for file in RECORDS_PATH.iterdir():
    if not file.is_file():
        continue
    data = file.read_text() # or read_bytes()
    # Translate things
    translated_file = file.with_name(f"{file.stem}-translasted.csv")
    translated_file.write(data)    

I will recommend you to read the documentation of pathlib.Path

Example:

from pathlib import Path

BASE_PATH = Path(...)

RECORDS_PATH = BASE_PATH / "records"

for file in RECORDS_PATH.iterdir():
    if not file.is_file():
        continue
    data = file.read_text() # or read_bytes()
    # Translate things
    translated_file = file.with_name(f"{file.stem}-translasted.csv")
    translated_file.write(data)    

使用Python通过文件夹中的多个文件循环函数

雄赳赳气昂昂 2025-02-03 17:43:10

我对在这里跌跌撞撞的任何人的建议 - 不要尝试自己的规范化,消化和签名。使用XMLSEC。尽管构建屁股的痛苦(我在Windows上),并且文档几乎不存在,但它可以完成工作。最终答案可以在这里找到:

My advice to anyone, who stumbles here is - DON'T try to canonicalize, digest and sign by yourself. Use xmlsec. Although it's pain in the ass to build (I'm on windows) and the documentation is almost non-existent, it gets the job done. The final answer can be found here:
Sign part of XML using xmlsec

如何使用XMLIB2典型化和消化肥皂的身体

雄赳赳气昂昂 2025-02-03 11:24:23

注册httpContextAccessor依赖关系。

builder.Services.AddHttpContextAccessor();
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddHttpContextAccessor();

// Register CurrentUserService
builder.Services.AddScoped<ICurrentUserService, CurrentUserService>();

var app = builder.Build();

参考

从自定义组件中使用httpcontext

Register HttpContextAccessor dependency.

builder.Services.AddHttpContextAccessor();
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddHttpContextAccessor();

// Register CurrentUserService
builder.Services.AddScoped<ICurrentUserService, CurrentUserService>();

var app = builder.Build();

References

Use HttpContext from custom components

ASP.NET Core Web API-无法解析类型的服务&#x27; ihttpcontextaccessor&#x27;试图激活services.currentuserservice&#x27;

雄赳赳气昂昂 2025-02-03 11:22:40
if (/localhost|10.0.2.2/.test(URL)) {
   //your code
}
if (/localhost|10.0.2.2/.test(URL)) {
   //your code
}

如何检查URL字符串是否包含2个子字符串?

雄赳赳气昂昂 2025-02-03 04:53:40

如果(a3-a2)是dateTime.timedelta类型,则可以使用

(a3-a2).total_seconds()

整个序列差异秒钟内转换为几秒钟

If (a3-a2) is a datetime.timedelta type, you can then use

(a3-a2).total_seconds()

To have the whole timedelta difference converted in seconds

将特定时间戳记为小时:分钟:从日志中的几秒钟,仅将其转换为秒

雄赳赳气昂昂 2025-02-03 02:51:52

要在C ++中使用多行字符串,您 can 使用Backsslash。

 cout << "You can build piramid which floor is only odd. \
not even" << '\n';

To use multi-line strings in C++, you can use backslash.

 cout << "You can build piramid which floor is only odd. \
not even" << '\n';

我想更舒适地使用cout

雄赳赳气昂昂 2025-02-02 13:21:35
   * Search recusively for files in a base directory matching a glob pattern.
   * The `GLOB_NOCHECK` flag has no effect.
   * @param  string $base Directory to search
   * @param  string $pattern Glob pattern to match files
   * @param  int $flags Glob flags from https://www.php.net/manual/function.glob.php
   * @return string[] Array of files matching the pattern
    
    
    
        function glob_recursive($base, $pattern, $flags = 0) {
            $flags = $flags & ~GLOB_NOCHECK;    
            if (substr($base, -1) !== DIRECTORY_SEPARATOR) {
                $base .= DIRECTORY_SEPARATOR;
            }
            $files = glob($base.$pattern, $flags);
            if (!is_array($files)) {
                $files = [];
            }
            $dirs = glob($base.'*', GLOB_ONLYDIR|GLOB_NOSORT|GLOB_MARK);
            if (!is_array($dirs)) {
                return $files;
            }   
            foreach ($dirs as $dir) {
                $dirFiles = glob_recursive($dir, $pattern, $flags);
                $files = array_merge($files, $dirFiles);
            }
            return $files;
        }
        
        $files = glob($base.$pattern, $flags);
        $files = $files !== false ? $files : [];
   * Search recusively for files in a base directory matching a glob pattern.
   * The `GLOB_NOCHECK` flag has no effect.
   * @param  string $base Directory to search
   * @param  string $pattern Glob pattern to match files
   * @param  int $flags Glob flags from https://www.php.net/manual/function.glob.php
   * @return string[] Array of files matching the pattern
    
    
    
        function glob_recursive($base, $pattern, $flags = 0) {
            $flags = $flags & ~GLOB_NOCHECK;    
            if (substr($base, -1) !== DIRECTORY_SEPARATOR) {
                $base .= DIRECTORY_SEPARATOR;
            }
            $files = glob($base.$pattern, $flags);
            if (!is_array($files)) {
                $files = [];
            }
            $dirs = glob($base.'*', GLOB_ONLYDIR|GLOB_NOSORT|GLOB_MARK);
            if (!is_array($dirs)) {
                return $files;
            }   
            foreach ($dirs as $dir) {
                $dirFiles = glob_recursive($dir, $pattern, $flags);
                $files = array_merge($files, $dirFiles);
            }
            return $files;
        }
        
        $files = glob($base.$pattern, $flags);
        $files = $files !== false ? $files : [];

递归搜索目录和子目录中的文件的方法,找不到文件

雄赳赳气昂昂 2025-02-02 06:38:41

你尝试过吗?

let req = indexedDB.deleteDatabase(databaseName);
req.onsuccess = function () {
    console.log("Deleted database successfully");
};
req.onerror = function () {
    console.log("Couldn't delete database");
};
req.onblocked = function () {
    console.log("Couldn't delete database due to the operation being blocked");

您也可以像这样手动删除它:

”在此处输入图像描述

Did you try?

let req = indexedDB.deleteDatabase(databaseName);
req.onsuccess = function () {
    console.log("Deleted database successfully");
};
req.onerror = function () {
    console.log("Couldn't delete database");
};
req.onblocked = function () {
    console.log("Couldn't delete database due to the operation being blocked");

Also you can manually delete it like this:

enter image description here

调查Chromium浏览器中的IndexEdDB存储并从JavaScript清洁

雄赳赳气昂昂 2025-02-02 00:15:42

您可以使用Expression API这样实现此信息:

public static Expression<Func<TEntity, bool>> QueryFilterBuilder<TEntity> 
(List<QueryFilter> filters)
{
    Expression GetExpressionForQueryFilter(QueryFilter filter, Expression param)
        => filter.Comparer switch
        {
            QueryFilterComparer.Eq => Expression.Equal(GetField(filter.Field, param), Expression.Constant(filter.Value)),
            QueryFilterComparer.Ne => Expression.Not(Expression.Equal(GetField(filter.Field, param), Expression.Constant(filter.Value))),
            QueryFilterComparer.Any => throw new NotImplementedException(),
            QueryFilterComparer.Gt => throw new NotImplementedException(),
            QueryFilterComparer.Gte => throw new NotImplementedException(),
            QueryFilterComparer.Lt => throw new NotImplementedException(),
            QueryFilterComparer.Lte => throw new NotImplementedException(),
            QueryFilterComparer.Contains => throw new NotImplementedException(),
            _ => throw new ArgumentOutOfRangeException()
    };

    Expression GetField(string field, Expression param)
    => Expression.Field(param, typeof(TEntity).GetField(field) ?? throw new ArgumentOutOfRangeException());

    var parameter = Expression.Parameter(typeof(TEntity), "parameter");

    return Expression.Lambda<Func<TEntity, bool>>(filters.Aggregate(
        (Expression) Expression.Constant(true),
        (acc, next) => Expression.MakeBinary(ExpressionType.AndAlso, acc, GetExpressionForQueryFilter(next, parameter))),
    parameter);
}

You can implement this using Expression api like so:

public static Expression<Func<TEntity, bool>> QueryFilterBuilder<TEntity> 
(List<QueryFilter> filters)
{
    Expression GetExpressionForQueryFilter(QueryFilter filter, Expression param)
        => filter.Comparer switch
        {
            QueryFilterComparer.Eq => Expression.Equal(GetField(filter.Field, param), Expression.Constant(filter.Value)),
            QueryFilterComparer.Ne => Expression.Not(Expression.Equal(GetField(filter.Field, param), Expression.Constant(filter.Value))),
            QueryFilterComparer.Any => throw new NotImplementedException(),
            QueryFilterComparer.Gt => throw new NotImplementedException(),
            QueryFilterComparer.Gte => throw new NotImplementedException(),
            QueryFilterComparer.Lt => throw new NotImplementedException(),
            QueryFilterComparer.Lte => throw new NotImplementedException(),
            QueryFilterComparer.Contains => throw new NotImplementedException(),
            _ => throw new ArgumentOutOfRangeException()
    };

    Expression GetField(string field, Expression param)
    => Expression.Field(param, typeof(TEntity).GetField(field) ?? throw new ArgumentOutOfRangeException());

    var parameter = Expression.Parameter(typeof(TEntity), "parameter");

    return Expression.Lambda<Func<TEntity, bool>>(filters.Aggregate(
        (Expression) Expression.Constant(true),
        (acc, next) => Expression.MakeBinary(ExpressionType.AndAlso, acc, GetExpressionForQueryFilter(next, parameter))),
    parameter);
}

通用类的谓词builder

雄赳赳气昂昂 2025-02-01 20:51:27

进入与班级相同的目录,

jar cfe top-level-window.jar TopLevelWindow TopLevelWindow.class

然后您可以

java -jar top-level-window.jar

鼓励适当的包装 - 不要只是使用默认包。

Move into the same directory as your class and do

jar cfe top-level-window.jar TopLevelWindow TopLevelWindow.class

You can then do

java -jar top-level-window.jar

I would encourage proper packaging though - don't just use the default package.

有没有一种方法可以从1。class文件中创建.jar文件,而没有Mac上的清单文件?

雄赳赳气昂昂 2025-02-01 19:24:15

我们将发票级别的折扣添加为调整(couse的负值)。您可以对偏好进行调整。

在API中,字段名称为“调整”和“ awithment_description”。这种方法对我们有用,尽管不是理想的。所有调整都涉及COA中的“其他费用”。

We add invoice level discount as an adjustment (with a negative value, of couse). You can enable adjustments in Preferences.

screenshot of Zoho Books add/edit invoice form

In API, the field names are "adjustment" and "adjustment_description". This method works for us, although not ideal. All adjustments go into "Other Charges" in COA.

如何在Entity_Level和tooks_level销售订单中添加折扣?

雄赳赳气昂昂 2025-02-01 19:12:00

尝试运行Python3.9 -M Pip install -u -u -user numpy-U表示升级,- 用户表示它将在您的用户文件夹中安装,而不是系统文件夹 - 它只是摆脱了该消息。

Numpy可以使用1.22版,因此pandas可能不适用于旧版本。

Try running python3.9 -m pip install -U --user numpy. -U means upgrade, and --user means it'll install in your user folder, not the system folder - it just gets rid of that message.

NumPy is up to version 1.22, so it's possible that pandas just doesn't work with the old version.

为python3.9安装numpy的麻烦

雄赳赳气昂昂 2025-02-01 15:04:31

添加此中间软件,它将起作用

app.use(function(req,res,next){
 var _send = res.send;
var sent = false;
res.send = function(data){
    if(sent) return;
    _send.bind(res)(data);
    sent = true;
};
next();
});

Add this middlware and it will work

app.use(function(req,res,next){
 var _send = res.send;
var sent = false;
res.send = function(data){
    if(sent) return;
    _send.bind(res)(data);
    sent = true;
};
next();
});

错误:将标题发送给客户端后可以设置标头

雄赳赳气昂昂 2025-02-01 10:52:33

您可以使用pandas熔体

x = [{'wow': 1,
  'item': 1,
  'money': 1},
 {'best': 1,
  'sock': 1,
  'saved': 1,
  'found': 1},
 {'cry': 1,
  'shock': 1,
  'sound': 1}]

df = pd.DataFrame(x)
df = df.melt().dropna().reset_index(drop=True)
df.columns = ['words', 'n']

输出:

”在此处输入图像说明”

You can use pandas melt

x = [{'wow': 1,
  'item': 1,
  'money': 1},
 {'best': 1,
  'sock': 1,
  'saved': 1,
  'found': 1},
 {'cry': 1,
  'shock': 1,
  'sound': 1}]

df = pd.DataFrame(x)
df = df.melt().dropna().reset_index(drop=True)
df.columns = ['words', 'n']

Output:

enter image description here

如何将字典列表转换为表

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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