在try / python除外之后停止运行程序(Stop program from running after try / except python)

我做了一个程序,它从treeview中获取值,并在按下按钮时计算一些东西。 我把try / except语句放在那个函数里面。

def SumAll():
    try:
       #do something (calculate)

    except ValueError:

        Error=messagebox.showinfo("Enter proper values")
        pass

问题是,当messagebox.showinfo出现时,程序会继续运行,并且会给出ValueError 。 我该如何解决这个问题,以及如何将多个错误异常( IndexError等)?


I made a program that takes values from treeview and calculate something when button is pressed. I put try / except statement inside that function.

def SumAll():
    try:
       #do something (calculate)

    except ValueError:

        Error=messagebox.showinfo("Enter proper values")
        pass

The problem is, program keeps running when messagebox.showinfo appears, and it gives the ValueError. How can I fix that, and how can I put more than one error exception (IndexError, etc)?


原文:https://stackoverflow.com/questions/49953598
2024-04-23 21:04

满意答案

由于您希望通过电子邮件发送HTML表格,因此您只需创建一个HTML表格,并在每次出错时添加一些行。 然后将其包含在您的电子邮件内容中并发送邮件。

$users = mysqli_query($con, "SELECT * FROM table");

// Table header
$htmlError = '<table><tr><th>ID</th><th>Column 1</th><th>Column 2</th></tr>';

while($row = mysqli_fetch_array($users)) {

    if  ($row['column1'] !=  $row['column2']) {
        // Add new row to table
        $htmlError .= '<tr><td>'.$row['id'].'</td><td>'.$row['column1'].'</td><td>'.$row['column2'].'</td></tr>';
    }
}

// End table
$htmlError .= '</table>';

// Send mail
...

As you want to send an HTML table by email, you just have to create an HTML table and add some lines each time you have an error. Then include it into your email's content and send the mail.

$users = mysqli_query($con, "SELECT * FROM table");

// Table header
$htmlError = '<table><tr><th>ID</th><th>Column 1</th><th>Column 2</th></tr>';

while($row = mysqli_fetch_array($users)) {

    if  ($row['column1'] !=  $row['column2']) {
        // Add new row to table
        $htmlError .= '<tr><td>'.$row['id'].'</td><td>'.$row['column1'].'</td><td>'.$row['column2'].'</td></tr>';
    }
}

// End table
$htmlError .= '</table>';

// Send mail
...

相关问答

更多

从基于android发送的电子邮件地址的服务器获取具有特定记录的列表视图(get list view with specific records from server based on email address sent from android)

我找到了答案,问题解决了 这是一个简单的解决方案 我只是把我的条件放在java代码中而没有改变PHP代码 变化是: try { JSONArray data = new JSONArray(getJSONUrl(url)); final ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>(); HashMap<String,...

使用jquery获取单个记录(get single records using jquery)

像这样在td元素中添加一个类: <tr> <td><input type="checkbox" name="case[]" class="case" ></td> <td><?php echo $abs['product_id']; ?></td> <td class="title"><?php echo $abs['product_title']; ?></td> <td class="email"><?php echo $abs['user_email']; ?...

保存记录后发送电子邮件 - rails(Send an email once record is saved - rails)

您是否在环境中设置了smtp设置? 像这样的东西: config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { # your settings } Have you set smtp settings in environment? Something like this: config.action_mailer.delivery_method = :smtp config.acti...

在rails中以逗号分隔的电子邮件列表创建多个记录(create multiple records from comma separated email list in rails)

所以,我想出来了,这是我的解决方案 调节器 def participant_invite @event = Event.find(params[:e]) end def add_participants @event = Event.find(params[:e]) @participant = params[:participant_invite][:email].split(/,\s*/) @participant.each do |t| newpart = Part...

PHP在电子邮件中发送数组记录(PHP Sending array records in email)

如果你想通过这样的邮件使用表显示所有细节, $data="<table><tr> <th></th> <th></th> </tr>"; while ($rowclient_credit=arrayfetch($getque)){ $rowcompany = $rowclient_credit['company']; $rowcredits = ...

从while循环获取一些记录到数组,然后通过电子邮件发送这些记录(Get some records from a while loop to an array, then send these records in an email)

由于您希望通过电子邮件发送HTML表格,因此您只需创建一个HTML表格,并在每次出错时添加一些行。 然后将其包含在您的电子邮件内容中并发送邮件。 $users = mysqli_query($con, "SELECT * FROM table"); // Table header $htmlError = '<table><tr><th>ID</th><th>Column 1</th><th>Column 2</th></tr>'; while($row = mysqli_fetch_arra...

如何确保salesforce中的工作流程没有触发电子邮件模板中没有记录/(How to make sure workflow in salesforce does not fire of there are no records in the email template/)

有一个汇总摘要,计算最重要的案例总数。 在工作流程输入条件中使用该汇总摘要字段。 I have used 2 workflow rules to achieve this requirement. 1. Time-Dependent WF Rule to update certain fields in contact which will be used to save the run time for the next email. 2. WF Rule with immediate acti...

MS Access:将验证字段添加到已通过电子邮件发送的记录中?(MS Access: Adding a verification field to records that have been emailed?)

不,选择查询无法更新。 但不知何故,您必须能够修改生成邮件的代码,以逐个更新表格记录并用时间戳标记每条记录。 然后,在邮寄时,用时间戳过滤掉记录。 No, a select query cannot update. But somehow you must be able to modify your code generating the mails to update the table records one by one marking each the record with a tim...

使用宏通过电子邮件发送报告,并在记录之间使用网格边框(using macro to send reports via email with gridline borders between records)

如果快照格式不是您的选项(它要求您的用户安装免费实用程序),那么您必须自己在代码中构建html,添加合适的表。 鉴于您之前的问题,这可能是要采取的路线,但它需要相当多的编码,但不一定在VBA中。 If snapshot format is not an option for you (it requires that your users install a free utility), then you must build the html yourself in code, adding s...

循环记录(Loop with records)

两个错误: 迭代元素是item iPar2 of varElevnavnIDliste ,而不是item 1 of ... 所请求元素的引用是Fornavn of item iPar2 of varElevnavnIDliste而不是Fornavn of varElevnavnIDliste 。 set varResult to {} repeat with iPar2 from 1 to (number of items in varElevnavnIDliste) if item iPa...

相关文章

更多

Running Solr with Maven

Solris an open source search server which is built ...

《编程之道 Java》(Program JAVA)[ISO]

本教材的第1章到第7章讲述了怎样学习Java和Java的基础知识,以及面向对象的编程思想;第8章到第1 ...

HDFS patch前后Ganglia看到running processes变化的分析

Ganglia running processes是怎么算出来的?ganglia是通过 cat /pr ...

Another MySQL daemon already running with the same unix socket.

两个方法解决: 第一个是立即关机 使用命令 shutdown -h now 关机,关机后在启动,进程就 ...

Python 写的Hadoop小程序

该程序是在python2.3上完成的,python版本间有差异。 Mapper: import sys ...

Mod_python: The Long Story

mod_python: the long story - Grisha Trubetskoy ...

探索 Python,第 1 部分: Python 的内置数值类型

Python 编程语言具有很高的灵活性,它支持多种编程方法,包括过程化的、面向对象的和函数式的。但最重 ...

python2和python3的区别

python2和python3的区别,1.性能 Py3.0运行 pystone benchmark的速 ...

Python的文件类型

Python的文件类型 Python有三种文件类型,分别是源代码文件、字节码文件和优化代码文件 源代 ...

python的下载与安装

python的官网:http://www.python.org/ 有两个版本,就像struts1和st ...

最新问答

更多

sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)

否(它不会使它们无法访问),是(您可以在没有停机的情况下运行它)。 sp_updatestats可以在没有停机的情况下针对实时数据库运行。 No (it doesn't make them inaccessible), and Yes (you can run it without downtime). sp_updatestats can be run against a live database without downtime.

如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)

最终,我们选择了使用Spark Framework for Java实现的后端REST API。 这可能不是最强大的,用户反馈一直是个问题。 我们将命令行界面拆分为提交REST调用,并将结果显示给用户。 Ultimately, we chose to go the route of having a backend REST API that was implemented with the Spark Framework for Java. This may not be the most r

AESGCM解密失败的MAC(AESGCM decryption failing with MAC)

您不能将Encoding.UTF8.GetString应用于任意二进制数据。 它只能解码使用UTF-8编码字符串的结果的字节。 .net实现将默默地破坏数据,而不是默认情况下抛出异常。 您应该使用Base64: Convert.FromBase64String和Convert.ToBase64String You can't apply Encoding.UTF8.GetString to arbitrary binary data. It can only decode bytes that

Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)

我希望能看到更多你的Sass代码等,但我的猜测是你需要在所有嵌套行上使用nest行为。 在我看来,基金会在Sass中的行主要是为了在一个层面上使用。 嵌套在另一行中的任何行都应使用nest行为,除非您希望在列上添加额外的填充。 在你的CodePen中,我能够通过向所有行添加一类collapse来修复列上填充的问题,我认为这与执行$behavior: nest相同$behavior: nest在Sass中$behavior: nest :

湖北京山哪里有修平板计算机的

京山有个联想的专卖店,那里卖平板电脑,地址在中百前面的十字路口右拐 ,他们应该会提供相关的维修服务。

SimplePie问题(SimplePie Problem)

我怀疑由于内容的性质(包含代码),stackoverflow提要不起作用。 我使用许多feed解析器看似“正常”的feed有类似的问题,尽管我最近运气最多的是Zend_Feed。 试试吧 I suspect the stackoverflow feed is not working due to the nature of the content (contains code). I have had similar issues with seemingly "normal" feeds us

在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)

是的,您可以通过getApplicationContext()任意数量的时间(后台任务), getApplicationContext()仅返回应用程序的context 。 Yes, you can pass getApplicationContext() any number of time (Background Tasks ) you want, getApplicationContext() simply returns context of the application.

HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)

这是我最终做的事情: 我无法以这种方式提供完全访问权限,而是在project level folder中设置了一个虚拟HTML页面,该页面单击自身以重定向到位于separate, non-project util folder的HTML文件。 这允许我保留除了那个之外的所有内容,非常小的文件分开但不存在文件访问问题。 Here is what I ended up doing: I wasn't able to provide full access exactly this way, but

为什么我会收到链接错误?(Why do I get a linker error?)

看起来您的编译器错误地将名称引入到全局名称空间中,而不是C ++ 11 3.5 / 7中指定的最内层名称空间( Bushman ): 如果没有找到具有链接的实体的块范围声明来引用某个其他声明,那么该实体是最内层封闭名称空间的成员。 代码按照预期在GCC上编译: http : //ideone.com/PR4KVC 你应该能够通过在构造函数的块作用域中声明它之前(或代替它)在正确的名称空间中声明该函数来解决该bug。 但是,我无法访问您的编译器来测试它。 It looks like your co

如何正确定义析构函数(How to properly define destructor)

在C ++中,你需要手动释放内存。 没有垃圾收集器。 您显然需要在析构函数内手动释放内存。 如果您使用new分配内存,则需要对在deconstructor中使用new分配的每个资源使用delete ,例如: class1::~class1(void) { delete resource1; delete resource2; etc... } In C++ you need to free the memory manually. There's no garbage