青衫负雪

文章 评论 浏览 29

青衫负雪 2025-02-08 03:14:41

您可以将图像的数组类型更改为元组:

normalized = resized/255,0

更改为:

normalized = resized/255

You change the array type of image to a tuple in:

normalized = resized/255,0

change to:

normalized = resized/255

我正在研究这个项目以进行实时面膜检测,但是我面临的错误无法将大小2的阵列重塑为形状(1,100,100,1)

青衫负雪 2025-02-07 18:51:44

删除我白名单上没有的所有电子邮件,

function deleteAllEmailsNotWhiteListed() {
  const acct = getGlobal('abrevEmail');
  var idA = [];
  GmailApp.getTrashThreads().forEach(t => { Gmail.Users.Threads.remove("me", t.getId()) });
  for (let k = 0; k < 2; k++) {
    switch (k) {
      case 0:
        var threads = GmailApp.getInboxThreads();
        break;
      case 1:
        var threads = GmailApp.getSpamThreads();
        break;
    }
    if (threads) {
      for (let i = 0; i < threads.length; i++) {
        const messages = threads[i].getMessages();
        if (messages) {
          for (let j = 0; j < messages.length; j++) {
            let msg = messages[j];
            let id = msg.getId();
            let sub = msg.getSubject().replace(/[^\s\w"!,?']/g, '');
            let from = msg.getFrom();
            let to = msg.getTo();
            let body = msg.getBody();
            let m = { id: id, from: from, to: to, subject: sub, account: acct }
            if (!isWhiteListed(m)) {
              idA.push(id);
            }
          }
        }
      }
    }
  }
  if (idA.length > 0) {
    var request = { "ids": idA };
    Gmail.Users.Messages.batchDelete(request, "me");
  }
}

function isWhiteListed(msg) {
  const ss = SpreadsheetApp.openById(getGlobal('ssid'));
  const sh = ss.getSheetByName(getGlobal('wlid'));
  const wlog = ss.getSheetByName(getGlobal('wlog'));
  const sr = 2;
  const rg = sh.getRange(sr, 1, sh.getLastRow() - sr + 1, 1);
  const wl = rg.getDisplayValues().flat().map(e => e.toLowerCase());
  if (wl.length == 0) throw ('Error: WhiteList has no content');
  let obj = decomposeEmailsWithTitle({ raw: msg.from, email: '', title: '' });
  let status = wl.indexOf(obj.email.toLowerCase()) > -1;
  wlog.appendRow([Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "E MMM dd, yyyy HH:mm:ss"), obj.email, msg.to, msg.subject, status, msg.account]);
  return status;
}

这是一个仅关注删除电子邮件的版本

function deleteAllEmailsNotWhiteListed() {
  const dt = new Date();
  const ydtv = new Date(dt.getFullYear(),dt.getMonth(), dt.getDate()-1).valueOf();
  const acct = getGlobal('abrevEmail');
  var idA = [];
  GmailApp.getTrashThreads().forEach(t => { Gmail.Users.Threads.remove("me", t.getId()) });
  for (let k = 0; k < 2; k++) {
    switch (k) {
      case 0:
        var threads = GmailApp.getInboxThreads();
        break;
      case 1:
        var threads = GmailApp.getSpamThreads();
        break;
    }
    if (threads) {
      for (let i = 0; i < threads.length; i++) {
        const messages = threads[i].getMessages();
        if (messages) {
          for (let j = 0; j < messages.length; j++) {
            let msg = messages[j];
            let id = msg.getId();
            let d = msg.getDate();
            let dtv = new Date(d.getFullYear(),d.getMonth(),d.getDate()).valueOf()
            if (dtv <= ydtv) {//modifed
              idA.push(id);
            }
          }
        }
      }
    }
  }
  if (idA.length > 0) {
    var request = { "ids": idA };
    Gmail.Users.Messages.batchDelete(request, "me");
  }
}

Deletes all emails that are not on my whitelist

function deleteAllEmailsNotWhiteListed() {
  const acct = getGlobal('abrevEmail');
  var idA = [];
  GmailApp.getTrashThreads().forEach(t => { Gmail.Users.Threads.remove("me", t.getId()) });
  for (let k = 0; k < 2; k++) {
    switch (k) {
      case 0:
        var threads = GmailApp.getInboxThreads();
        break;
      case 1:
        var threads = GmailApp.getSpamThreads();
        break;
    }
    if (threads) {
      for (let i = 0; i < threads.length; i++) {
        const messages = threads[i].getMessages();
        if (messages) {
          for (let j = 0; j < messages.length; j++) {
            let msg = messages[j];
            let id = msg.getId();
            let sub = msg.getSubject().replace(/[^\s\w"!,?']/g, '');
            let from = msg.getFrom();
            let to = msg.getTo();
            let body = msg.getBody();
            let m = { id: id, from: from, to: to, subject: sub, account: acct }
            if (!isWhiteListed(m)) {
              idA.push(id);
            }
          }
        }
      }
    }
  }
  if (idA.length > 0) {
    var request = { "ids": idA };
    Gmail.Users.Messages.batchDelete(request, "me");
  }
}

function isWhiteListed(msg) {
  const ss = SpreadsheetApp.openById(getGlobal('ssid'));
  const sh = ss.getSheetByName(getGlobal('wlid'));
  const wlog = ss.getSheetByName(getGlobal('wlog'));
  const sr = 2;
  const rg = sh.getRange(sr, 1, sh.getLastRow() - sr + 1, 1);
  const wl = rg.getDisplayValues().flat().map(e => e.toLowerCase());
  if (wl.length == 0) throw ('Error: WhiteList has no content');
  let obj = decomposeEmailsWithTitle({ raw: msg.from, email: '', title: '' });
  let status = wl.indexOf(obj.email.toLowerCase()) > -1;
  wlog.appendRow([Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "E MMM dd, yyyy HH:mm:ss"), obj.email, msg.to, msg.subject, status, msg.account]);
  return status;
}

Here's a version that only concerns itself with the deleting emails that are older than The current date

function deleteAllEmailsNotWhiteListed() {
  const dt = new Date();
  const ydtv = new Date(dt.getFullYear(),dt.getMonth(), dt.getDate()-1).valueOf();
  const acct = getGlobal('abrevEmail');
  var idA = [];
  GmailApp.getTrashThreads().forEach(t => { Gmail.Users.Threads.remove("me", t.getId()) });
  for (let k = 0; k < 2; k++) {
    switch (k) {
      case 0:
        var threads = GmailApp.getInboxThreads();
        break;
      case 1:
        var threads = GmailApp.getSpamThreads();
        break;
    }
    if (threads) {
      for (let i = 0; i < threads.length; i++) {
        const messages = threads[i].getMessages();
        if (messages) {
          for (let j = 0; j < messages.length; j++) {
            let msg = messages[j];
            let id = msg.getId();
            let d = msg.getDate();
            let dtv = new Date(d.getFullYear(),d.getMonth(),d.getDate()).valueOf()
            if (dtv <= ydtv) {//modifed
              idA.push(id);
            }
          }
        }
      }
    }
  }
  if (idA.length > 0) {
    var request = { "ids": idA };
    Gmail.Users.Messages.batchDelete(request, "me");
  }
}

根据特定标准删除Gmails

青衫负雪 2025-02-07 04:50:05

使用:

<div class="collapse in " [ngClass]="(active_tab=='assignservice' || active_tab=='manage')?'show':''" id="collapseExampleOrganization" aria-expanded="true" style="">
    <ul>
        <li class="nav-item" [ngClass]="{'active': active_tab=='manage'}">
            <a routerLink="/main/organization/manage" (click)="activemenu('manage')"> <i class="la la-building-o"></i>
               <p>Manage</p></a></li>
        <li class="nav-item" [ngClass]="{'active': active_tab=='assignservice'}"><a routerLink="/main/organization/assignservice" (click)="activemenu('assignservice')"><i class="la la-user"></i><p>Add organization</p></a></li>
    </ul>
</div>

该代码是ngclass 的一个很好的例子,如果 - else 条件。

[ngClass]="(active_tab=='assignservice' || active_tab=='manage')?'show':''"

[ngClass]="{'active': active_tab=='assignservice'}"

Use:

<div class="collapse in " [ngClass]="(active_tab=='assignservice' || active_tab=='manage')?'show':''" id="collapseExampleOrganization" aria-expanded="true" style="">
    <ul>
        <li class="nav-item" [ngClass]="{'active': active_tab=='manage'}">
            <a routerLink="/main/organization/manage" (click)="activemenu('manage')"> <i class="la la-building-o"></i>
               <p>Manage</p></a></li>
        <li class="nav-item" [ngClass]="{'active': active_tab=='assignservice'}"><a routerLink="/main/organization/assignservice" (click)="activemenu('assignservice')"><i class="la la-user"></i><p>Add organization</p></a></li>
    </ul>
</div>

The code is a good example of an ngClass if-else condition.

[ngClass]="(active_tab=='assignservice' || active_tab=='manage')?'show':''"

[ngClass]="{'active': active_tab=='assignservice'}"

Angular: *ngclass的有条件类

青衫负雪 2025-02-06 19:53:29

手写圆的某些部分(在线间距区域)可以提取,假设“许多字母在同一行上对齐”。我认为,在您的图像中,将提取圆的上部和下部。

然后,如果从提取的部分开始跟踪黑线(假设曲率平滑),则可以检测到连接的手写圆圈。

但是……实际上,我认为这样的过程会遇到许多困难:尤其是关于通过删除曲线切断角色的事实。

Some Parts of handwritten circles (on line spacing regions) may be able to extract, with the assumption "many letters align on same line". In your image, upper and lower part of the circle will be extracted, I think.

Then, if you track the black line with starting from the extracted part (with assuming smooth curvature), it may be able to detect the connected handwritten circle.

However... in real, I think such process will encounter many difficulties : especially regarding the fact that characters will be cut off by removing curve.

从扫描图像中删除手写的圆形注释

青衫负雪 2025-02-06 18:33:55
from pyspark.sql import SparkSession
from pyspark.sql import functions as F

from pyspark.sql.types import *
from datetime import datetime
from pyspark.sql import *
from collections import *
from pyspark.sql.functions import udf,explode
from pyspark.sql.types import StringType
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession

spark = SparkSession(sc)

df= spark.createDataFrame(
    [
        ('0018aad4', [{"val1":"blue", "val2":"red"}],[300,500]), 
         ('0018aad', [{"val1":"blue", "val2":"null"}],[300])
       
        ],("ID","List","Tlist")
    )

df2 = df.select(df.ID,explode(df.List).alias("Dict"),df.Tlist )
df2.withColumn("Val1", F.col("Dict").getItem("val1")).withColumn("Val2", F.col("Dict").getItem("val2")).show(truncate=False)


+--------+----------------------------+----------+----+----+
|ID      |Dict                        |Tlist     |Val1|Val2|
+--------+----------------------------+----------+----+----+
|0018aad4|{val2 -> red, val1 -> blue} |[300, 500]|blue|red |
|0018aad |{val2 -> null, val1 -> blue}|[300]     |blue|null|

+--------+--------------------------------------+-----------+ -----+ ----+

这是您要寻找的。

from pyspark.sql import SparkSession
from pyspark.sql import functions as F

from pyspark.sql.types import *
from datetime import datetime
from pyspark.sql import *
from collections import *
from pyspark.sql.functions import udf,explode
from pyspark.sql.types import StringType
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession

spark = SparkSession(sc)

df= spark.createDataFrame(
    [
        ('0018aad4', [{"val1":"blue", "val2":"red"}],[300,500]), 
         ('0018aad', [{"val1":"blue", "val2":"null"}],[300])
       
        ],("ID","List","Tlist")
    )

df2 = df.select(df.ID,explode(df.List).alias("Dict"),df.Tlist )
df2.withColumn("Val1", F.col("Dict").getItem("val1")).withColumn("Val2", F.col("Dict").getItem("val2")).show(truncate=False)


+--------+----------------------------+----------+----+----+
|ID      |Dict                        |Tlist     |Val1|Val2|
+--------+----------------------------+----------+----+----+
|0018aad4|{val2 -> red, val1 -> blue} |[300, 500]|blue|red |
|0018aad |{val2 -> null, val1 -> blue}|[300]     |blue|null|

+--------+----------------------------+----------+----+----+

this is what you are looking for.

pyspark:将dict阵列转到新列

青衫负雪 2025-02-06 07:43:56

不确定我会说这是可扩展的,但是对于字母,我将

const letters = ["A","B".."Z"]

function generateRandomLetterArray(){
let randomLetterArr = []

for(i=0, i<{how every many random letters you want}, i++){

let randomNumber = {math random number between 0 and 25 (because there are 26 letters)}

randomLetter = letters[randomNumber]
randomLetterArr.push(randomLetter)
}
}

在此时添加到一个数组

not sure I would say this is scalable, but for the letters I would add the to an array

const letters = ["A","B".."Z"]

function generateRandomLetterArray(){
let randomLetterArr = []

for(i=0, i<{how every many random letters you want}, i++){

let randomNumber = {math random number between 0 and 25 (because there are 26 letters)}

randomLetter = letters[randomNumber]
randomLetterArr.push(randomLetter)
}
}

at this point you have a bunch of random letters in randomLetterArr

我必须在代码上添加什么才能使我的按钮在每个矩形上返回不同的随机数?

青衫负雪 2025-02-05 21:16:16

您已经有一个用户数据,并且想在输入中绑定它以创建用户配置文件吗?如果是,您可以在模板中使用 vor 指令在数组上迭代。

演示

new Vue({
  el: '#app',
  data: {
    users: [{
      name: "Fred",
      phone: "00997878",
      email: "[email protected]",
      age: "20"
    },{
      name: "Tom",
      phone: "0998899",
      email: "[email protected]",
      age: "23"
    }]
  },
  methods: {
    createprofile() {
        console.log(this.users);
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <div v-for="(user, index) in users" :key="index">
    <input id="email" v-model="user.email" type="text" placeholder="Email">
    <input id="name" v-model="user.name" type="text" placeholder="Name">
    <input id="phone" v-model="user.phone" type="text" placeholder="Phone no.">
    <input id="age" v-model="user.age" type="text" placeholder="Age">
  </div><br>
  <button @click="createprofile()">Submit</button>
</div>

You already have a user data and want to bind that in inputs to create a user profile ? If Yes, You can use v-for directive in the template to iterate over an array.

Demo :

new Vue({
  el: '#app',
  data: {
    users: [{
      name: "Fred",
      phone: "00997878",
      email: "[email protected]",
      age: "20"
    },{
      name: "Tom",
      phone: "0998899",
      email: "[email protected]",
      age: "23"
    }]
  },
  methods: {
    createprofile() {
        console.log(this.users);
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <div v-for="(user, index) in users" :key="index">
    <input id="email" v-model="user.email" type="text" placeholder="Email">
    <input id="name" v-model="user.name" type="text" placeholder="Name">
    <input id="phone" v-model="user.phone" type="text" placeholder="Phone no.">
    <input id="age" v-model="user.age" type="text" placeholder="Age">
  </div><br>
  <button @click="createprofile()">Submit</button>
</div>

从vue.js中存储在JavaScript上的数组中的用户输入

青衫负雪 2025-02-05 19:16:27

您可以用计数器对象来计算外观,然后进行最频繁的外观:

from collections import Counter

column = ("S", "A", "A", "A", "D", "S-A", "A")

counter = Counter(column)
# returns a sorted list of elements and number of appearances
frequencies = counter.most_common()

# grab the first (most common) element and its frequency.
most_frequent_element, frequency = fequencies[0]

print(most_frequent_element, frequency)

输出:

A 4

You can count the appearances with the Counter object and then take the most frequent appearance:

from collections import Counter

column = ("S", "A", "A", "A", "D", "S-A", "A")

counter = Counter(column)
# returns a sorted list of elements and number of appearances
frequencies = counter.most_common()

# grab the first (most common) element and its frequency.
most_frequent_element, frequency = fequencies[0]

print(most_frequent_element, frequency)

output:

A 4

如何在滚动间隔上选择最常见的类别 /文本?

青衫负雪 2025-02-05 12:26:53

多亏了T3RR0R,它起作用了。

@echo off
chcp 65001

for /f "tokens=*" %%a IN ('dir /b /o:-d *.log') do (
    call :ChercheSucc %%a
    )
)

:RienTrouve
echo Pas de succès
pause
exit 1 /b

:TrouveFichier
set FichierTrouve=%~1
echo %FichierTrouve%
echo Trouvé !
pause
exit 0 /b

:ChercheSucc
findstr /i /m /c:"SUCC" %~1 >nul
if %errorlevel%==0 goto TrouveFichier

Thanks to T3RR0R, it worked.

@echo off
chcp 65001

for /f "tokens=*" %%a IN ('dir /b /o:-d *.log') do (
    call :ChercheSucc %%a
    )
)

:RienTrouve
echo Pas de succès
pause
exit 1 /b

:TrouveFichier
set FichierTrouve=%~1
echo %FichierTrouve%
echo Trouvé !
pause
exit 0 /b

:ChercheSucc
findstr /i /m /c:"SUCC" %~1 >nul
if %errorlevel%==0 goto TrouveFichier

在日志文件中搜索字符串(最新的第一个),并显示第一次发现

青衫负雪 2025-02-05 09:36:45

这就是熊猫数据框架中的预期行为。

在您的情况下, procinject1 存储数据框的字符串表示形式,即使相应的数据框为空,这也是非空框的。

例如,请选中以下代码段,其中我创建一个空的数据框 df 并检查其字符串表示:

df = pd.DataFrame()
print(df.to_string(index = False)) 
print(df.to_string(index = True))

既适用 index = false and code> index = index = true 案例,输出将相同,如下所示(这是预期的行为)。因此,您对应的 len()将始终返回非零。

Empty DataFrame
Columns: []
Index: []

但是,如果您使用非空置框架,则为 index = false and index = true 案例的输出将有所不同:

data = [{'A': 10, 'B': 20, 'C':30}, {'A':5, 'B': 10, 'C': 15}]
df = pd.DataFrame(data)
print(df.to_string(index = False)) 
print(df.to_string(index = True))

然后是的输出index = false index = true 案例将是 -

A  B  C
10 20 30
5 10 15

    A   B   C
0  10  20  30
1   5  10  15

由于Pandas对空数据框的处理方式有所不同,要解决您的问题,您应该首先检查您的数据帧是否为空,请使用 pandas.dataframe.empty.empty

然后,如果数据帧实际上是非空的,则可以打印该数据框的字符串表示形式,同时保留 index = false 以隐藏索引列。

That's the expected behaviour in Pandas DataFrame.

In your case, procinject1 stores the string representation of the dataframe, which is non-empty even if the corresponding dataframe is empty.

For example, check the below code snippet, where I create an empty dataframe df and check it's string representation:

df = pd.DataFrame()
print(df.to_string(index = False)) 
print(df.to_string(index = True))

For both index = False and index = True cases, the output will be the same, which is given below (and that is the expected behaviour). So your corresponding len() will always return non-zero.

Empty DataFrame
Columns: []
Index: []

But if you use a non-empty dataframe, then the outputs for index = False and index = True cases will be different as given below:

data = [{'A': 10, 'B': 20, 'C':30}, {'A':5, 'B': 10, 'C': 15}]
df = pd.DataFrame(data)
print(df.to_string(index = False)) 
print(df.to_string(index = True))

Then the outputs for index = False and index = True cases respectively will be -

A  B  C
10 20 30
5 10 15

    A   B   C
0  10  20  30
1   5  10  15

Since pandas handles empty dataframes differently, to solve your problem, you should first check whether your dataframe is empty or not, using pandas.DataFrame.empty.

Then if the dataframe is actually non-empty, you could print the string representation of that dataframe, while keeping index = False to hide the index column.

即使DataFrame为空,TO_STRING(index = false)即使是非空字符串的结果

青衫负雪 2025-02-04 19:28:57

在通过互联网搜索时,我发现它可能与保险库策略设置有关。因此,我终于能够使这件事变得有效,我不得不将 data 附加在库中成功阅读的路径。因为当我研究组织的策略文档时,数据是在事实上附加的。

const vault = require("node-vault")({
    apiVersion: "v1",
    endpoint: "vaultURL",
  });

const GITHUB_TOKEN = '';

const run = async () => {
 try {
  const result = await vault.githubLogin({ token: GITHUB_TOKEN });
  
  vault.token = result.auth.client_token;
  console.log('Client Token', vault.token);

  const { data : { data } }  = await vault.read("root/data/path");  // <---- important
    console.log('data', data);
 } catch (error) {
   console.log(error.message);
 }
};

run();

我最初的道路是
秘密/apikey

必须使用
秘密/data/apikey

用于参考“>这个在github上的答案。

On searching over the internet I found that It might have something to do with the vault policy settings. So, I was finally able to get this thing to work, I had to append data in the path for a successful read from the vault. Because data was in-fact appended with the path when I looked into the organisation's policy document.

const vault = require("node-vault")({
    apiVersion: "v1",
    endpoint: "vaultURL",
  });

const GITHUB_TOKEN = '';

const run = async () => {
 try {
  const result = await vault.githubLogin({ token: GITHUB_TOKEN });
  
  vault.token = result.auth.client_token;
  console.log('Client Token', vault.token);

  const { data : { data } }  = await vault.read("root/data/path");  // <---- important
    console.log('data', data);
 } catch (error) {
   console.log(error.message);
 }
};

run();

My original path was
secret/apiKey

Had to use
secret/data/apiKey

For reference take a look at this answer on github.

当尝试通过github令牌身份验证读取node js中的hasicorp保险库时,为什么我会获得权限拒绝错误

青衫负雪 2025-02-04 08:08:27

This is working as per design , state will randomly generated unique value is typically used for preventing cross-site request forgery attacks. The state is also used to encode information about the user's state in the app , see the docs for more details - https://learn.microsoft.com/en-us/graph/auth-v2-user
enter image description here

Microsoft Oauth解析状态参数作为字符串,但返回哈希

青衫负雪 2025-02-04 04:43:48

可以通过创建扩展 AbstractCelleditor 并实施 TableCelleDitor 的私人类来解决。然后创建并自定义滚动条。这是示例。

public class MainForm {
    private JTable table1;
    private JPanel panel1;
    private JTextArea text = new JTextArea();

    public MainForm() {
        text.setEditable(false);
        DefaultTableModel tableModel = new DefaultTableModel(new Object[][]{}, new String[]{"Meno", "Priezvisko", "Datum", "Popis"});
        table1.setModel(tableModel);
        table1.setRowHeight(40);
        tableModel.addRow(new Object[]{"Jaimi", "Parker", "2022", "fdjfadufaouifasoifjasifhasiofa \nasdasdasdasdasdasdas \nasdasdasdasdasdasd\nasdasdasdasd "});
        tableModel.addRow(new Object[]{"William", "Mcdonald", "2021", "fdjfadufaouasfadfdsfafifasoifjasifhasiofa"});
        tableModel.addRow(new Object[]{"Matt", "Ashley", "2020", "asfasfafdsfgdafgdfgasgsdg"});
        tableModel.addRow(new Object[]{"Ariana", "Burns", "2019", "fdjfadufaouifasfdsgdgagsgsdgsdgsdagsdgsdgsdgsagsdgoifjasifhasiofa"});

        TableColumn column = table1.getColumn("Popis");
        column.setCellEditor(new HScrollableTCE());
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame("MainForm");
        frame.setContentPane(new MainForm().panel1);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }

    private class HScrollableTCE extends AbstractCellEditor implements TableCellEditor
    {
        JScrollPane scroll = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int vColIndex)
        {
            if (value != null) {
                scroll.setHorizontalScrollBar(scroll.createHorizontalScrollBar());
                scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 5));

                scroll.setBorder(new EmptyBorder(0,0,0,0));
                scroll.setToolTipText(value.toString());
                text.setText(value.toString());
                return scroll;
            }
            return null;
        }
        public Object getCellEditorValue()
        {
            return text.getText();
        }
    }

}

It can be solved by creating private class that extends AbstractCellEditor and implements TableCellEditor. Then create and customize the scrollbar. Here is example.

public class MainForm {
    private JTable table1;
    private JPanel panel1;
    private JTextArea text = new JTextArea();

    public MainForm() {
        text.setEditable(false);
        DefaultTableModel tableModel = new DefaultTableModel(new Object[][]{}, new String[]{"Meno", "Priezvisko", "Datum", "Popis"});
        table1.setModel(tableModel);
        table1.setRowHeight(40);
        tableModel.addRow(new Object[]{"Jaimi", "Parker", "2022", "fdjfadufaouifasoifjasifhasiofa \nasdasdasdasdasdasdas \nasdasdasdasdasdasd\nasdasdasdasd "});
        tableModel.addRow(new Object[]{"William", "Mcdonald", "2021", "fdjfadufaouasfadfdsfafifasoifjasifhasiofa"});
        tableModel.addRow(new Object[]{"Matt", "Ashley", "2020", "asfasfafdsfgdafgdfgasgsdg"});
        tableModel.addRow(new Object[]{"Ariana", "Burns", "2019", "fdjfadufaouifasfdsgdgagsgsdgsdgsdagsdgsdgsdgsagsdgoifjasifhasiofa"});

        TableColumn column = table1.getColumn("Popis");
        column.setCellEditor(new HScrollableTCE());
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame("MainForm");
        frame.setContentPane(new MainForm().panel1);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }

    private class HScrollableTCE extends AbstractCellEditor implements TableCellEditor
    {
        JScrollPane scroll = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int vColIndex)
        {
            if (value != null) {
                scroll.setHorizontalScrollBar(scroll.createHorizontalScrollBar());
                scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 5));

                scroll.setBorder(new EmptyBorder(0,0,0,0));
                scroll.setToolTipText(value.toString());
                text.setText(value.toString());
                return scroll;
            }
            return null;
        }
        public Object getCellEditorValue()
        {
            return text.getText();
        }
    }

}

在特定列中制作可jt的单元

青衫负雪 2025-02-03 18:29:01
def load_csv(filename):
    category = pd.read_csv(filename, nrows=0).columns.str.replace('(\.\d+)

我想到了。但这太丑了。

,'') category_subset = pd.read_csv(filename, skiprows=1, nrows=0).columns.str.replace('\:.*','').str.replace('(\.\d+)

我想到了。但这太丑了。

,'') df = pd.read_csv(filename, header=2) df.columns = category + ": " + category_subset + ": " + df.columns return df

我想到了。但这太丑了。

def load_csv(filename):
    category = pd.read_csv(filename, nrows=0).columns.str.replace('(\.\d+)

I came up with this. But it's so ugly.

,'') category_subset = pd.read_csv(filename, skiprows=1, nrows=0).columns.str.replace('\:.*','').str.replace('(\.\d+)

I came up with this. But it's so ugly.

,'') df = pd.read_csv(filename, header=2) df.columns = category + ": " + category_subset + ": " + df.columns return df

I came up with this. But it's so ugly.

使用pd.read_csv加载CSV,然后返回带有从标题中解析的列名的DF

青衫负雪 2025-02-03 16:02:45

您可以尝试下面的代码以显示在随机方法返回价值后要购买餐点的人的名称。

# get the input names of friends separated by comma
names=input("Enter the names of every person separated by a comma")
# get the list of names by splitting the string above using the comma delimiter
name_collection=names.split(",")
# get the random index of the person who is going to pay for the bills
choice=random.randint(0,len(name_collection))
#print the name of the person who is going to buy the meal
print(name_colection[choice])

You can try the code below to display the name of the person who is going to buy the meal after the random method returns a value.

# get the input names of friends separated by comma
names=input("Enter the names of every person separated by a comma")
# get the list of names by splitting the string above using the comma delimiter
name_collection=names.split(",")
# get the random index of the person who is going to pay for the bills
choice=random.randint(0,len(name_collection))
#print the name of the person who is going to buy the meal
print(name_colection[choice])

python3-列表转换为int,如何将其返回到int之前的原始值

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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