漫雪独思

文章 评论 浏览 29

漫雪独思 2025-02-20 21:19:47

在program.cs中执行此操作

builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddDbContext<URMSContext>((serviceProvider, dbContextBuilder) =>
{
    var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
    
    // extract configsection from this path
    var configSectionName = httpContextAccessor.HttpContext.Request.Path; 
    
    var dbConfig = Configuration
        .GetSection(configSectionName + "Configs")
        .Get<MyConfiguration>();
    dbContextBuilder.UseSqlServer(dbConfig.ConnectionString);
});

do this in program.cs

builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddDbContext<URMSContext>((serviceProvider, dbContextBuilder) =>
{
    var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
    
    // extract configsection from this path
    var configSectionName = httpContextAccessor.HttpContext.Request.Path; 
    
    var dbConfig = Configuration
        .GetSection(configSectionName + "Configs")
        .Get<MyConfiguration>();
    dbContextBuilder.UseSqlServer(dbConfig.ConnectionString);
});

如何根据路由值选择配置部分

漫雪独思 2025-02-20 17:53:19

至少就三角学部分而言,您是如此亲密。

在处理方面,您只缺少 setup() and draw()它将绘制一个帧(一旦您取消注册 rotx的作业,roty,roty < /code>和初始化 Angle to 0)

这是您的代码,上面的注释:

float rotX, rotY;
float angle = 0;

void setup() {
  size(500, 500);

  fill(#B71143);
}

void draw() {

  int rectX=width/4;
  int rectY=height/10;

  int rectSize=30;
  angle=angle+0.1;
  
  rotX = rectX*cos(angle)-rectY*sin(angle);
  rotY = rectX*cos(angle)+rectY*sin(angle);
  
  
  square(rotX, rotY, rectSize);
}

此外,如果要从中心绘制,则可以在渲染之前将宽度/高度的一半添加到方形坐标(相等的要翻译成中心),如果您想绘制一个圆而不是椭圆形,请使用两个RADII的大小(命名 rectx,retecty,retecty ):

float rotX, rotY;
float angle = 0;

void setup() {
  size(500, 500);

  fill(#B71143);

  rectMode(CENTER);
}

void draw() {

  int rectX=width/4;
  int rectY=height/4;

  int rectSize=30;
  angle=angle+0.1;
  
  rotX = rectX*cos(angle)-rectY*sin(angle);
  rotY = rectX*cos(angle)+rectY*sin(angle);
  
  // offset to center
  rotX += width / 2;
  rotY += height / 2;
  
  square(rotX, rotY, rectSize);
}

就我个人而言,我会有点简化代码(尽管您的作业要求可能会根据您的课程而有所不同)。

// initialise angle value
float angle = 0;

void setup() {
  size(500, 500);

  fill(#B71143);
}

void draw() {
  // circular motion radius
  int radius = width / 4;
  // define square size
  int rectSize=30;
  // increment the angle (rotating around center)
  angle=angle+0.1;
  // convert polar (angle, radius) to cartesian(x,y) coords
  float x = cos(angle) * radius;
  float y = sin(angle) * radius;
  
  // offset to center
  x += width / 2;
  y += height / 2;
  // render the square at the rotated position
  square(x, y, rectSize);
}

(如果您是沿着笛卡尔坐标的另一个极地转换公式的说明,则可以在这里查看我的较旧答案其中包括互动演示)

You are so close, at least in terms of the trigonometry part.

In terms of Processing you're only missing setup() and draw() which will draw a single frame (once you uncomment the assignments of rotX, rotY and initialise angle to 0)

Here's your code with above notes applied:

float rotX, rotY;
float angle = 0;

void setup() {
  size(500, 500);

  fill(#B71143);
}

void draw() {

  int rectX=width/4;
  int rectY=height/10;

  int rectSize=30;
  angle=angle+0.1;
  
  rotX = rectX*cos(angle)-rectY*sin(angle);
  rotY = rectX*cos(angle)+rectY*sin(angle);
  
  
  square(rotX, rotY, rectSize);
}

Additionally, if you want to draw from the centre, you can add half the width/height to the square coordinates before rendering (equivalent to translating to centre), and if you want to draw a circle instead of an oval, use the same size for the two radii (named rectX, rectY):

float rotX, rotY;
float angle = 0;

void setup() {
  size(500, 500);

  fill(#B71143);

  rectMode(CENTER);
}

void draw() {

  int rectX=width/4;
  int rectY=height/4;

  int rectSize=30;
  angle=angle+0.1;
  
  rotX = rectX*cos(angle)-rectY*sin(angle);
  rotY = rectX*cos(angle)+rectY*sin(angle);
  
  // offset to center
  rotX += width / 2;
  rotY += height / 2;
  
  square(rotX, rotY, rectSize);
}

Personally I'd simplify the code a bit (though your assignment requirements might differ based on your curriculum).

// initialise angle value
float angle = 0;

void setup() {
  size(500, 500);

  fill(#B71143);
}

void draw() {
  // circular motion radius
  int radius = width / 4;
  // define square size
  int rectSize=30;
  // increment the angle (rotating around center)
  angle=angle+0.1;
  // convert polar (angle, radius) to cartesian(x,y) coords
  float x = cos(angle) * radius;
  float y = sin(angle) * radius;
  
  // offset to center
  x += width / 2;
  y += height / 2;
  // render the square at the rotated position
  square(x, y, rectSize);
}

(In case you're after another polar to cartesian coordinates conversion formula explanation you can check out my older answer here which includes an interactive demo)

我想在Java处理中以圆形运动移动一个正方形

漫雪独思 2025-02-20 11:26:55

与*args和** kwargs

*args ** kwargs 只是某种方法,可以将无限的字符输入函数,例如:


def print_all(*args, **kwargs):
    print(args) # print any number of arguments like: "print_all("foo", "bar")"
    print(kwargs.get("to_print")) # print the value of the keyworded argument "to_print"


# example:
print_all("Hello", "World", to_print="!")
# will print:
"""
('Hello', 'World')
!
"""

"Infinite" Args with *args and **kwargs

*args and **kwargs are just some way to input unlimited characters to functions, like:


def print_all(*args, **kwargs):
    print(args) # print any number of arguments like: "print_all("foo", "bar")"
    print(kwargs.get("to_print")) # print the value of the keyworded argument "to_print"


# example:
print_all("Hello", "World", to_print="!")
# will print:
"""
('Hello', 'World')
!
"""

**(双星/星号)和 *(星/星号)对参数有什么作用?

漫雪独思 2025-02-20 03:17:06

手动真空/分析

还原新数据库后还原后,尚无列统计信息。通常, autovacuum 最终会启动,但是由于“数据[...]不更改” autovacuum 不会触发。

出于相同的原因(数据不更改),我建议在还原单个表后一次运行一次:

VACUUM (ANALYZE, FREEZE) users;

对于从未更改的表格,您不妨运行 freeze
完整不需要,因为刚修复的表中没有死元

。主要问题:

  1. 不良列统计
  2. 数据库配置不良(更严重的问题)

请参见:

在慢速db中,Postgres期望行= 2714 ,期望行= 2130 在快速中。差异可能似乎并不大,但可能足以将Postgres转向另一个查询计划(事实证明是次要的)。

看到Postgres实际上找到行= 122836 估计要么不好。慢速DB中的一个实际上是少> 。但是,位图扫描的速度比索引扫描要慢,即使排位赛的排比预期还要多。 (!),因此您的数据库配置很可能已经离去了。主要问题通常是默认 Random_page_cost 4 ,而完全缓存的仅读取表的现实设置更接近 1 。也许1.1允许一些额外费用。还有其他几个设置可以鼓励索引扫描。例如 。从这里开始:

eastera : 估计。列统计也是:统计。因此不准确,但会受到随机变化的影响。您可能会增加统计目标以提高列统计的有效性。

廉价随机读取有利于索引扫描并劝阻位图索引扫描。
更合格的行有利于位图索引扫描。不太喜欢索引扫描。请参阅:

Manual VACUUM / ANALYZE after restore

After restoring a new database, there are no column statistics yet. Normally, autovacuum will kick in eventually, but since "data [...] isn't changing", autovacuum wouldn't be triggered.

For the same reason (data isn't changing), I suggest to run this once after restoring your single table:

VACUUM (ANALYZE, FREEZE) users;

You might as well run FREEZE for a table that's never changed.
(FULL isn't necessary, since there are no dead tuples in a freshly restored table.)

Explanation for the plan change

With everything else being equal, I suspect at least two major problems:

  1. Bad column statistics
  2. Bad database configuration (the more severe problem)

See:

In the slow DB, Postgres expects rows=2714, while it expects rows=2130 in the fast one. The difference may not seem huge, but may well be enough to tip Postgres over to the other query plan (that turns out to be inferior).

Seeing that Postgres actually finds rows=122836, either estimate is bad. The one in the slow DB is actually less bad. But the bitmap scan turns out to be slower than the index scan, even with many more qualifying rows than expected. (!) So your database configuration is most probably way off. The main problem typically is the default random_page_cost of 4, while a realistic setting for fully cached read-only table is much closer to 1. Maybe 1.1 to allow for some additional cost. There are a couple other settings that encourage index scans. Like effective_cache_size. Start here:

Estimates are just that: estimates. And column statistics are also just that: statistics. So not exact but subject to random variation. You might increase the statistics target to increase the validity of column statistics.

Cheap random reads favor index scans and discourage bitmap index scans.
More qualifying rows favor a bitmap index scan. Less favor an index scan. See:

查询在复制数据库后减慢5倍(在同一台计算机上!)

漫雪独思 2025-02-20 00:48:12

我首先要构造一个尺寸为“ value”的映射“ id”,然后使用它来附加值。

PC_List = [[1,1,2],[1,2,8],[1,3,5],[2,4,7],[3,5,1]]
values = {k: v for _, k, v in PC_List}

output = [[p, c, v, values[p]] for p, c, v in PC_List]
print(output)
# [[1, 1, 2, 2], [1, 2, 8, 2], [1, 3, 5, 2], [2, 4, 7, 8], [3, 5, 1, 5]]

I would first construct a dict that maps "id" to the "value", and then use it to append the values.

PC_List = [[1,1,2],[1,2,8],[1,3,5],[2,4,7],[3,5,1]]
values = {k: v for _, k, v in PC_List}

output = [[p, c, v, values[p]] for p, c, v in PC_List]
print(output)
# [[1, 1, 2, 2], [1, 2, 8, 2], [1, 3, 5, 2], [2, 4, 7, 8], [3, 5, 1, 5]]

python从嵌套列表父母元素中查找值

漫雪独思 2025-02-19 20:51:29

这里的问题在于 body 需要是某种特定类型,因此ProviderView需要是某种特定类型(因为 Body 依赖于该类型)。它在运行时无法更改。因此,如果在运行时会更改,ProviderView不能对其提供商进行通用。

这意味着 providerView.provider 需要为任何提供商而不是通用:

struct ProviderView: View {
    let provider: any Provider

    var body: some View {
        Text(String(describing: type(of: provider.get())))
    }
}

因此,该部分是可以预期的。

您会遇到的问题是当前的运行时尚无法完全处理,稍后您会出现错误:

// Runtime support for parameterized protocol types is only available in iOS 99.0.0 or newer
ProviderView(provider: s.stringProvider)

我希望以后的Beta在Beta中有所改善,尽管我鼓励您打开跟踪它的反馈。

The problem here is that body needs to be some specific type, so ProviderView needs to be some specific type (since body relies on that type). It can't change at runtime. So ProviderView can't be generic over its Provider if that's going to change at runtime.

That means that ProviderView.provider needs to be any Provider, not generic:

struct ProviderView: View {
    let provider: any Provider

    var body: some View {
        Text(String(describing: type(of: provider.get())))
    }
}

So that part is expected.

The problem you'll run into is that the current runtime can't quite handle this yet, and you'll get an error later:

// Runtime support for parameterized protocol types is only available in iOS 99.0.0 or newer
ProviderView(provider: s.stringProvider)

I do expect this to improve in later betas, though I encourage you to open a Feedback to track it.

Swift 5.7存在的问题

漫雪独思 2025-02-19 10:53:12

您可以修改扩展Panellist 调用 ExpandedHeaderPadding 上的空间/填充。

ExpansionPanelList(
  expandedHeaderPadding: EdgeInsets.zero,
  children: [
    ExpansionPanel(

ListTile提供基于

maxHeight: (isDense ? 48.0 : 56.0) + densityAdjustment.dy,

您创建自定义行小部件的默认高度。

ExpansionPanel(
  headerBuilder: (BuildContext context, bool isExpanded) {
    return ListTile(
      title: Text("Files (2)"),
      leading: Icon(Icons.folder_outlined),
      minLeadingWidth: 4,
      contentPadding:
          EdgeInsets.symmetric(vertical: 0.0, horizontal: 0.0),
    );
  },
  body: Column(
    children: [
      ...List.generate(
          3,
          (index) => Padding(
                padding: const EdgeInsets.only(left: 8.0, top: 4),
                child: Row(
                  //decorate items the way you like
                  children: [
                    Icon(Icons.insert_drive_file),
                    SizedBox(
                      width: 16,
                    ),
                    Text("File_$index"),
                  ],
                ),
              ))
    ],
  ),
  isExpanded: true,
),

More about expandedHeaderPadding and expassionpanellist flutter.dev上。

You can modify the space/padding on ExpansionPanelList calling expandedHeaderPadding.

ExpansionPanelList(
  expandedHeaderPadding: EdgeInsets.zero,
  children: [
    ExpansionPanel(

listTile provide default height based on

maxHeight: (isDense ? 48.0 : 56.0) + densityAdjustment.dy,

You can create custom row widget for this.

ExpansionPanel(
  headerBuilder: (BuildContext context, bool isExpanded) {
    return ListTile(
      title: Text("Files (2)"),
      leading: Icon(Icons.folder_outlined),
      minLeadingWidth: 4,
      contentPadding:
          EdgeInsets.symmetric(vertical: 0.0, horizontal: 0.0),
    );
  },
  body: Column(
    children: [
      ...List.generate(
          3,
          (index) => Padding(
                padding: const EdgeInsets.only(left: 8.0, top: 4),
                child: Row(
                  //decorate items the way you like
                  children: [
                    Icon(Icons.insert_drive_file),
                    SizedBox(
                      width: 16,
                    ),
                    Text("File_$index"),
                  ],
                ),
              ))
    ],
  ),
  isExpanded: true,
),

More about expandedHeaderPadding and ExpansionPanelList on flutter.dev.

如何降低颤动中膨胀元素元素之间的空间?

漫雪独思 2025-02-19 08:53:06

尝试以下操作:

SELECT
MAX(Rank),
[Alloted Quota],
[Alloted Institute],
Course,
[Alloted Category]
FROM  Table
WHERE  
[Alloted Institute] = N'Govern...'  
GROUP BY 
 [Alloted Quota],
 [Alloted Institute],
 Course,
 [Alloted Category]

try this:

SELECT
MAX(Rank),
[Alloted Quota],
[Alloted Institute],
Course,
[Alloted Category]
FROM  Table
WHERE  
[Alloted Institute] = N'Govern...'  
GROUP BY 
 [Alloted Quota],
 [Alloted Institute],
 Course,
 [Alloted Category]

查询访问数据库检索数据吗?

漫雪独思 2025-02-18 06:23:40

我做错了什么吗?这只是DB2的不兼容问题,它不会返回生成的值?如果是这样,解决此问题的最佳解决方案是什么?

是的,你做错了。这不是不兼容的问题,也不是问题。 DB2与MySQL不同。您无法处理两者,因为您的DDL不兼容。由于没有任何记录插入DB2中,因此键的值不可用。

问题的解决方案是在插入记录上创建触发器,以确保将主键插入DB中。如果您缺少键,请从序列中选择它并替换值。

现在,如果这样的身份生成了DB2

CREATE TABLE STUDENT
(
  ID INTEGER DEFAULT IDENTITY GENERATED ALWAYS NOT NULL
  PRIMARY KEY (ID)
)

,因此它将始终返回 getGeneratedKeys()

Am I doing something wrong? Is this just an incompatibility issue with DB2 and it just does not return the generated value? If so, what would be the best solution for tackling this issue?

Yes, you are doing wrong. It's not incompatibility issue, and it's not an issue. DB2 is different than MySQL. You can't handle both because you have incompatible DDL. Since no records are inserted into DB2 the value of the key is not available.

The solution to the issue is to create a trigger on insert a record to make sure the primary key is inserted into DB. If you are missing a key then select it from the sequence and substitute the value.

Now if identity is generated into DB2 like this

CREATE TABLE STUDENT
(
  ID INTEGER DEFAULT IDENTITY GENERATED ALWAYS NOT NULL
  PRIMARY KEY (ID)
)

So it will always return getGeneratedKeys().

Java准备的陈述获得生成的键不能在DB2中工作,而是在MySQL中工作吗?

漫雪独思 2025-02-17 17:41:19
import firebase from "firebase/app";
import "firebase/firestore";
import "firebase/auth";

firebase.initializeApp({

});

const auth = firebase.auth();
const firestore = firebase.firestore();

export { auth, firestore };

尝试此代码

import firebase from "firebase/app";
import "firebase/firestore";
import "firebase/auth";

firebase.initializeApp({

});

const auth = firebase.auth();
const firestore = firebase.firestore();

export { auth, firestore };

TRY THIS CODE

Firebas Firestore

漫雪独思 2025-02-17 07:55:34

我认为您的方法中使用ID HTML属性的问题,并且因为将有一个以上的电池,因此ID不会是唯一的。

最好使用样式指令,而不是通过ID更改样式。

我只是修复了问题,并在代码中制作了一些难治性。

https://codesandbox.io/s/battery-forked-forked-forked-1ze0jx

I think the issue in your approach that you use id html attribute for the style, and because there will be more than one battery so the id will not be unique.

It would better to use Style directive instead of changing style by id.

I just fixed the issue and make some refractory in the code.

https://codesandbox.io/s/battery-forked-1ze0jx

Vue Props数据....您可以带一个吗?

漫雪独思 2025-02-16 13:18:35

这是因为查询每次执行CRON作业时都会获取所有数据。另外,您尚未在elasticsearch输出中提供自定义 id ,因此它将为每个文档创建动态ID,因此,索引中将有更多数据(具有不同唯一ID的重复数据)。

您可以使用 sql_last_value param 哪个存储了最后一个爬网日期,并使用create_date或updated_date上的条件更新查询。这将首次获得DB的所有数据,并且仅次于新创建或更新的数据。

input {
  jdbc {
    jdbc_driver_library => "/correct_path/java/mysql-connector-java-8.0.27.jar" 
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/my_db"
    jdbc_user => "user" 
    jdbc_password => "password" 
    jdbc_paging_enabled => true
    schedule => "*/5 * * * * *"
    statement => 'select * from my_table where created_date > :sql_last_value or updated_date > :sql_last_value'
  }
}

output {
    elasticsearch {
      user => "test"
      password => "test"
      hosts => ["localhost:9200"] 
      index => "my_index"
    }
    stdout { codec => "rubydebug" }
}

PS:我不是SQL中的专业人士,因此我的查询可能会出现问题。但是我希望你能得到这个主意。

This is happening because query will get all the data every time when the cron job will be executed. Also, you have not provided custom id in elasticsearch output so it will create dynamic id for each document and due to that there will be more data in index (duplicate data with different unique id).

You can use sql_last_value param which store the last crawl date and update your query with where condition on created_date or updated_date. This will get first time all the data from DB and second time onward only data which are newly created or updated.

input {
  jdbc {
    jdbc_driver_library => "/correct_path/java/mysql-connector-java-8.0.27.jar" 
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/my_db"
    jdbc_user => "user" 
    jdbc_password => "password" 
    jdbc_paging_enabled => true
    schedule => "*/5 * * * * *"
    statement => 'select * from my_table where created_date > :sql_last_value or updated_date > :sql_last_value'
  }
}

output {
    elasticsearch {
      user => "test"
      password => "test"
      hosts => ["localhost:9200"] 
      index => "my_index"
    }
    stdout { codec => "rubydebug" }
}

PS: I am not pro in SQL so my query might have issue. But I hope you will get the idea.

LogStash JDBC插件比实际数据填充Elasticsearch中更多的数据,继续运行

漫雪独思 2025-02-16 09:20:52

JavaScript中有两种类型的范围。

  1. 全局范围:在全局范围中宣布的变量可以非常顺利地使用。例如:

      var carname =“ bmw”;
    
    //这里的代码可以使用carname
    
    功能myFunction(){
         //这里的代码可以使用carname 
    }
     
  2. 功能范围或本地范围:在此范围中声明的变量只能在其自身函数中使用。例如:

      //这里的代码无法使用carname
    功能myFunction(){
       var carname =“ bmw”;
       //这里的代码可以使用carname
    }
     

There are two types of scopes in JavaScript.

  1. Global scope: variable which is announced in global scope can be used anywhere in the program very smoothly. For example:

    var carName = " BMW";
    
    // code here can use carName
    
    function myFunction() {
         // code here can use carName 
    }
    
  2. Functional scope or Local scope: variable declared in this scope can be used in its own function only. For example:

    // code here can not use carName
    function myFunction() {
       var carName = "BMW";
       // code here can use carName
    }
    

JavaScript中变量的范围是什么?

漫雪独思 2025-02-16 06:20:24
list1 = [{'symbol': 'EOS/USD:USD-220930', 'type': 'limit', 'side': 'buy', 'price': 0.7, 'amount': 1.0},
         {'symbol': 'EOS/USD:USD-220930', 'type': 'limit', 'side': 'buy', 'price': 0.75, 'amount': 2.0}]

result = False
for d in list1:
    if d.get('side') == 'buy':
        result = True
        break

print(result)
list1 = [{'symbol': 'EOS/USD:USD-220930', 'type': 'limit', 'side': 'buy', 'price': 0.7, 'amount': 1.0},
         {'symbol': 'EOS/USD:USD-220930', 'type': 'limit', 'side': 'buy', 'price': 0.75, 'amount': 2.0}]

result = False
for d in list1:
    if d.get('side') == 'buy':
        result = True
        break

print(result)

字典列表的价值等于“字符串”。然后给出结果真实

漫雪独思 2025-02-16 03:12:58

您可以提取所有英语和中文单词,并加入一个空间:

import pandas as pd
df = pd.DataFrame({'Title':['補水法

You can extract all English and Chinese words and join with a space:

import pandas as pd
df = pd.DataFrame({'Title':['補水法????', '???? 現貨 ????', 'Text, text'], 'Content':['Skin Care', 'รีบจัดด่วน‼️ ราคาเฉพาะรอบนี???? Test', 'More text!!!']})

pPunct = r'!-/\:-@\[-`\{-~\u00A1-\u00A9\u00AB\u00AC\u00AE-\u00B1\u00B4\u00B6-\u00B8\u00BB\u00BF\u00D7\u00F7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u037E\u0384\u0385\u0387\u03F6\u0482\u055A-\u055F\u0589\u058A\u058D-\u058F\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0606-\u060F\u061B\u061D-\u061F\u066A-\u066D\u06D4\u06DE\u06E9\u06FD\u06FE\u0700-\u070D\u07F6-\u07F9\u07FE\u07FF\u0830-\u083E\u085E\u0888\u0964\u0965\u0970\u09F2\u09F3\u09FA\u09FB\u09FD\u0A76\u0AF0\u0AF1\u0B70\u0BF3-\u0BFA\u0C77\u0C7F\u0C84\u0D4F\u0D79\u0DF4\u0E3F\u0E4F\u0E5A\u0E5B\u0F01-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F85\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u104A-\u104F\u109E\u109F\u10FB\u1360-\u1368\u1390-\u1399\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DB\u1800-\u180A\u1940\u1944\u1945\u19DE-\u19FF\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B6A\u1B74-\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2010-\u2027\u2030-\u205E\u207A-\u207E\u208A-\u208E\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2775\u2794-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u303F\u309B\u309C\u30A0\u30FB\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAA77-\uAA79\uAADE\uAADF\uAAF0\uAAF1\uAB5B\uAB6A\uAB6B\uABEB\uFB29\uFBB2-\uFBC2\uFD3E-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD\U00010100-\U00010102\U00010137-\U0001013F\U00010179-\U00010189\U0001018C-\U0001018E\U00010190-\U0001019C\U000101A0\U000101D0-\U000101FC\U0001039F\U000103D0\U0001056F\U00010857\U00010877\U00010878\U0001091F\U0001093F\U00010A50-\U00010A58\U00010A7F\U00010AC8\U00010AF0-\U00010AF6\U00010B39-\U00010B3F\U00010B99-\U00010B9C\U00010EAD\U00010F55-\U00010F59\U00010F86-\U00010F89\U00011047-\U0001104D\U000110BB\U000110BC\U000110BE-\U000110C1\U00011140-\U00011143\U00011174\U00011175\U000111C5-\U000111C8\U000111CD\U000111DB\U000111DD-\U000111DF\U00011238-\U0001123D\U000112A9\U0001144B-\U0001144F\U0001145A\U0001145B\U0001145D\U000114C6\U000115C1-\U000115D7\U00011641-\U00011643\U00011660-\U0001166C\U000116B9\U0001173C-\U0001173F\U0001183B\U00011944-\U00011946\U000119E2\U00011A3F-\U00011A46\U00011A9A-\U00011A9C\U00011A9E-\U00011AA2\U00011C41-\U00011C45\U00011C70\U00011C71\U00011EF7\U00011EF8\U00011FD5-\U00011FF1\U00011FFF\U00012470-\U00012474\U00012FF1\U00012FF2\U00016A6E\U00016A6F\U00016AF5\U00016B37-\U00016B3F\U00016B44\U00016B45\U00016E97-\U00016E9A\U00016FE2\U0001BC9C\U0001BC9F\U0001CF50-\U0001CFC3\U0001D000-\U0001D0F5\U0001D100-\U0001D126\U0001D129-\U0001D164\U0001D16A-\U0001D16C\U0001D183\U0001D184\U0001D18C-\U0001D1A9\U0001D1AE-\U0001D1EA\U0001D200-\U0001D241\U0001D245\U0001D300-\U0001D356\U0001D6C1\U0001D6DB\U0001D6FB\U0001D715\U0001D735\U0001D74F\U0001D76F\U0001D789\U0001D7A9\U0001D7C3\U0001D800-\U0001D9FF\U0001DA37-\U0001DA3A\U0001DA6D-\U0001DA74\U0001DA76-\U0001DA83\U0001DA85-\U0001DA8B\U0001E14F\U0001E2FF\U0001E95E\U0001E95F\U0001ECAC\U0001ECB0\U0001ED2E\U0001EEF0\U0001EEF1\U0001F000-\U0001F02B\U0001F030-\U0001F093\U0001F0A0-\U0001F0AE\U0001F0B1-\U0001F0BF\U0001F0C1-\U0001F0CF\U0001F0D1-\U0001F0F5\U0001F10D-\U0001F1AD\U0001F1E6-\U0001F202\U0001F210-\U0001F23B\U0001F240-\U0001F248\U0001F250\U0001F251\U0001F260-\U0001F265\U0001F300-\U0001F6D7\U0001F6DD-\U0001F6EC\U0001F6F0-\U0001F6FC\U0001F700-\U0001F773\U0001F780-\U0001F7D8\U0001F7E0-\U0001F7EB\U0001F7F0\U0001F800-\U0001F80B\U0001F810-\U0001F847\U0001F850-\U0001F859\U0001F860-\U0001F887\U0001F890-\U0001F8AD\U0001F8B0\U0001F8B1\U0001F900-\U0001FA53\U0001FA60-\U0001FA6D\U0001FA70-\U0001FA74\U0001FA78-\U0001FA7C\U0001FA80-\U0001FA86\U0001FA90-\U0001FAAC\U0001FAB0-\U0001FABA\U0001FAC0-\U0001FAC5\U0001FAD0-\U0001FAD9\U0001FAE0-\U0001FAE7\U0001FAF0-\U0001FAF6\U0001FB00-\U0001FB92\U0001FB94-\U0001FBCA'
pLatin = r'A-Za-z\u00AA\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uAB66-\uAB69\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A\U00010780-\U00010785\U00010787-\U000107B0\U000107B2-\U000107BA\U0001DF00-\U0001DF1E'
pHan = r'\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFA6D\uFA70-\uFAD9\U00016FE2\U00016FE3\U00016FF0\U00016FF1\U00020000-\U0002A6DF\U0002A700-\U0002B738\U0002B740-\U0002B81D\U0002B820-\U0002CEA1\U0002CEB0-\U0002EBE0\U0002F800-\U0002FA1D\U00030000-\U0003134A'
pEmojiEx = r'0-9\u00A9\u00AE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299\U0001F004\U0001F0CF\U0001F170\U0001F171\U0001F17E\U0001F17F\U0001F18E\U0001F191-\U0001F19A\U0001F1E6-\U0001F1FF\U0001F201\U0001F202\U0001F21A\U0001F22F\U0001F232-\U0001F23A\U0001F250\U0001F251\U0001F300-\U0001F321\U0001F324-\U0001F393\U0001F396\U0001F397\U0001F399-\U0001F39B\U0001F39E-\U0001F3F0\U0001F3F3-\U0001F3F5\U0001F3F7-\U0001F4FD\U0001F4FF-\U0001F53D\U0001F549-\U0001F54E\U0001F550-\U0001F567\U0001F56F\U0001F570\U0001F573-\U0001F57A\U0001F587\U0001F58A-\U0001F58D\U0001F590\U0001F595\U0001F596\U0001F5A4\U0001F5A5\U0001F5A8\U0001F5B1\U0001F5B2\U0001F5BC\U0001F5C2-\U0001F5C4\U0001F5D1-\U0001F5D3\U0001F5DC-\U0001F5DE\U0001F5E1\U0001F5E3\U0001F5E8\U0001F5EF\U0001F5F3\U0001F5FA-\U0001F64F\U0001F680-\U0001F6C5\U0001F6CB-\U0001F6D2\U0001F6D5-\U0001F6D7\U0001F6DD-\U0001F6E5\U0001F6E9\U0001F6EB\U0001F6EC\U0001F6F0\U0001F6F3-\U0001F6FC\U0001F7E0-\U0001F7EB\U0001F7F0\U0001F90C-\U0001F93A\U0001F93C-\U0001F945\U0001F947-\U0001F9FF\U0001FA70-\U0001FA74\U0001FA78-\U0001FA7C\U0001FA80-\U0001FA86\U0001FA90-\U0001FAAC\U0001FAB0-\U0001FABA\U0001FAC0-\U0001FAC5\U0001FAD0-\U0001FAD9\U0001FAE0-\U0001FAE7\U0001FAF0-\U0001FAF6'
pat = fr'[{pHan}{pLatin}{pPunct}]+'

df = df.replace(fr'[{pEmojiEx}]+', '', regex=True)
df['Title'] = df['Title'].str.findall(pat).str.join(" ")
df['Content'] = df['Content'].str.findall(pat).str.join(" ")
print(df.to_string())

Output:

>>> df
        Title       Content
0         補水法     Skin Care
1          現貨          Test
2  Text, text  More text!!!

What it does is:

  • df.replace(fr'[{pEmojiEx}]+', '', regex=True) removes all chars that are marked with Emoji Unicode property (these include digits, but I removed * and #)
  • .str.findall(fr'[{pHan}{pLatin}{pPunct}]+').str.join(" ") extracts chunks of one or more Latin, Han or any punctuation chars and joins them with a space.

如何在数据框架中删除表情符号和其他语言

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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