每次用新数据写入文件(被修改)并且我使用Python时,我想执行一个函数.
我该怎么做?
我正在编写一个可以进行音频分析的应用程序(用作吉他调音器,增加了和弦估计和其他一些东西),但我在使用GUI时遇到了一些问题.第一个问题是我有一个按钮,点击后应更改其显示的文本.单击它时,文本不会更改,但是应该更改应该更改它的代码行.
另一件事是我需要一个SwingWorker来重复执行(一旦完成就重新启动)并每次更新GUI.正如我的代码目前,我有一个while循环重复执行我的SwingWorker,但这导致GUI变得无响应,因为它在EDT中运行(大概).让SwingWorker重复执行的最佳方法是什么?我应该创建一个新线程来运行循环,还是其他什么?
我内部ActionListener类的代码如下:
private class TunerListener implements ActionListener {
private boolean firstUpdate = true;
private volatile boolean executing = false;
private final SwingWorker<Void, Void> tunerWorker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
model.update();
return null;
}
@Override
protected void done() {
if (!this.isCancelled()) {
prev.setText(model.getPrev());
currentNote.setText(model.getNote());
next.setText(model.getNext());
frequency.setText(model.getFrequency());
switch (model.getOffset()) {
case -2:
light_2.setIcon(onRed);
light_1.setIcon(off);
light0.setIcon(offBig);
light1.setIcon(off);
light2.setIcon(off);
break;
case -1:
light_2.setIcon(off);
light_1.setIcon(onRed);
light0.setIcon(offBig);
light1.setIcon(off);
light2.setIcon(off);
break;
case 0:
light_2.setIcon(off);
light_1.setIcon(off);
light0.setIcon(onGreen);
light1.setIcon(off);
light2.setIcon(off);
break;
case 1: …Run Code Online (Sandbox Code Playgroud) 我的网站上有一个奇怪的问题.只要单击链接,文件就会执行两次.我注意到这一点的唯一原因是因为当我提交关键字的搜索请求时,我会在MySQL数据库中记录搜索.数据库总是保存两个记录(有一个时间戳,有时在同一秒添加记录,但通常只相隔一秒).我知道我是网站上唯一的一个,并且查询没有被循环调用.所以我做了一个fopen($ file,'a')来查看将添加多少行代码,并且大部分时间都添加了两行代码.我可以添加一条记录的唯一方法是连续2-3次运行相同的搜索.
所以我唯一能想到的就是我们在网站上有广告.我能想象的唯一一件事就是当我点击链接时,与广告相关联的javascript也会遵循相同的链接.
还有其他好主意吗?
我正在通过perl脚本执行一个unix命令来获取一个direcory的大小.
$path = "/dir1/di2/";
system("du -sh $path");
Run Code Online (Sandbox Code Playgroud)
如何在perl脚本中返回结果.
我在用
$size = system("du -sh $path");
print $size
Run Code Online (Sandbox Code Playgroud)
但它给出size = 0;
在搜索到直到疯狂之后,我决定在这里发一个问题.我尝试创建一个sqlite3数据库,我想利用cursor.execute(SQL,param)函数的安全变量替换函数.我的功能是这样的:
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import sqlite3
def create():
values = ("data")
sql = "CREATE TABLE IF NOT EXISTS ? ( name TEXT, street TEXT, time REAL, age INTEGER )"
con = sqlite3.connect("database.db")
c = con.cursor()
c.execute(sql, values)
con.commit()
c.close()
con.close()
if __name__ = "__main__":
create()
Run Code Online (Sandbox Code Playgroud)
我知道第一个参数应该是字符串形式的sql命令,第二个参数必须是应该替换的值的元组?在sql字符串中.但是,当我运行该文件时,它返回以下错误:
$ ./test.py
Traceback (most recent call last):
File "./test.py", line 21, in <module>
create()
File "./test.py", line 14, in create
c.execute(sql, values)
sqlite3.OperationalError: near "?": syntax error
Run Code Online (Sandbox Code Playgroud)
当paramstyle设置为named(例如:table表单)时,也会发生这种情况.我在这里找不到语法错误,所以我认为问题必定是在系统中的某个地方引起的.我在Archlinux和Debian安装上测试了它,都给我发了同样的错误.
现在你好了,因为我不知道在哪里寻找原因.
您好,以下是我的代码.我需要使用视图中的数据创建一个视图并在另一个游标中获取数据.但是当我执行我的代码时,我收到错误
"ORA-06550:第56行,第37列:PL/SQL:ORA-00942:表或视图不存在ORA-06550:第52行,第9列:PL/SQL:忽略SQL语句"
这是什么问题?提前致谢.
declare
drop_view_sql varchar2(100) := 'drop view rv_task_number_view';
type tasks_rec is record(task_number varchar2(20));
type t_tab is table of tasks_rec;
tasks_tab t_tab;
notes_rec xx_fs_mob_loc_rec.task_notes_rec;
notes_tab xx_fs_mob_loc_rec.task_notes_tab;
begin
execute immediate 'create view apps.rv_task_number_view as
SELECT distinct ct.task_number
FROM csf_ct_tasks ct ,
cs_estimate_details ced,
csf_debrief_headers cdh,
csf_debrief_lines cdl,
jtf_task_assignments jta
WHERE 1=1
and jta.task_id = ct.task_id
and jta.task_assignment_id = cdh.task_assignment_id(+)
and cdh.debrief_header_id = cdl.debrief_header_id(+)
and cdl.debrief_line_id = ced.source_id(+)
AND ((ct.planned_end_date between (sysdate-30) and (sysdate+30)) or (ct.scheduled_end_date between (sysdate-30) and (sysdate+30)))
and …Run Code Online (Sandbox Code Playgroud) 我有一个名为stmt的Statement对象,Connection对象conn.
stmt = conn.createStatement();
boolean b = stmt.execute("INSERT INTO employee VALUES('E001', 'Smith')")
Run Code Online (Sandbox Code Playgroud)
但这总是产生错误.如果上面的查询成功执行,我想要真实,如果查询执行失败,我想要假.如何使用execute()方法实现该结果.
我有问题动态调用存储过程
\n\n v_sql := 'begin '|| p_procname || '(''test1'','' test2 '',:v_output2); end;';\n execute immediate v_sql\n using out v_output2 ;\n dbms_output.put_line(v_output2 || ' ' );\nRun Code Online (Sandbox Code Playgroud)\n\n在这里 \xc4\xb1 可以调用立即执行的过程。\n但我的问题是动态绑定变量。该值来自日志表,然后我解析execute_immediate 过程
\n\n v_sql := 'begin '|| p_procname || '(''test1'','' test2'',:v_output2); end;';\n v_sql1:= ||using|| 'out v_output2 ' ;\n\n execute immediate v_sql\n v_sql1;\nRun Code Online (Sandbox Code Playgroud)\n\n它不是那样工作的。我如何使动态变量绑定,因为我调用了很多过程,并且该过程具有不同的输入和输出参数。\n我希望你能理解我遇到的问题。我该如何解决这个问题,谢谢
\n我想运行我的delphi程序,但我需要查看特定循环执行的次数.我记得在学校使用Delphi 7时我们曾经设置它,以便在运行时它一次只能运行1行而不是一次运行所有这些行.遗憾的是,在我的生活中,我不记得如何做到这一点.
如何将Delphi设置为一次只运行一行并要求您在运行下一行之前将其向前移动?