为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > [异常处理]python异常处理

[异常处理]python异常处理

2018-04-29 14页 doc 38KB 25阅读

用户头像

is_435706

暂无简介

举报
[异常处理]python异常处理[异常处理]python异常处理 [异常处理]python异常处理 篇一 : python异常处理 #!/usr/bin/python import traceback try: 1/0 #except Exception,e: # print traceback.format_exc except Exception as e: print e #!/usr/bin/python import traceback try: 1/0 #except Exception,e: # print tra...
[异常处理]python异常处理
[异常处理]python异常处理 [异常处理]python异常处理 篇一 : python异常处理 #!/usr/bin/python import traceback try: 1/0 #except Exception,e: # print traceback.format_exc except Exception as e: print e #!/usr/bin/python import traceback try: 1/0 #except Exception,e: # print traceback.format_exc except Exception , e: print e Python的异常处理能力是很强大的,可向用户准确反馈出错信息。。 例: try: raise MyError #自己抛出一个异常 except MyError: print „a error? raise ValueError,’invalid argument’ 捕捉到的内容为: type = VauleError message = invalid argument 3. 采用traceback模块查看异常 发生异常时,Python能“记住”引发的异常以及程序的当前状态。Python还维护着traceback对象,其中含有异常发生时与函数调用堆栈有关的信息。记住,异常可能在一系列嵌套较深的函数调用中引发。程序调用每个函数时,Python会在“函数调用堆栈”的起始处插入函数名。一旦异常被引发,Python会搜索一个相应的异常处理程序。如果当前函数中没有异常处理程序,当前函数会终止执行,Python会搜索当前函数的调用函数,并以此类推,直到发现匹配的异常处理程序,或者Python抵达主程序为止。这一查找合适的异常处理程序的过程就称为“堆栈辗转开解”。解释器一方面维护着与放置堆栈中的函数有关的信息,另一方面也维护着与已从堆栈中“辗转开解”的函数 有关的信息。 格式: try: block except: traceback.print_exc 示例:…excpetion/traceback.py 4. 采用sys模块回溯最后的异常 import sys try: block except: info=sys.exc_info print info[0],”:”,info[1] 或者以如下的形式: import sys tp,val,td = sys.exc_info sys.exc_info的返回值是一个tuple, 这里的type ---- 异常的类型 value/message ---- 异常的信息或者参数 traceback ---- 包含调用栈信息的对象。 从这点上可以看出此方法涵盖了traceback. 5. 异常处理的一些其它用途 除了处理实际的错误条件之外,对于异常还有许多其它的用处。在 Python 库中一个普通的用法就是试着导入一个模块,然后检查是否它能使用。导入一个并不存在的模块将引发一个 ImportError 异常。你可以使用这种方法来定义多级别的功能――依靠在运行时哪个模块是有效的,或支持多种平台 。 你也能通过创建一个从内置的 Exception 类继承的类定义你自己的异常,然后使用 raise 命令引发你的异常。如果你对此感兴趣,请看进一步阅读的部分。 下面的例子演示了如何使用异常支持特定平台功能。代码来自 getpass 模块,一个从用户获得口令的封装模块。获得口令在 UNIX、Windows 和 Mac OS 平台上的实现是不同的,但是这个代码封装了所有的不同之处。 例支持特定平台功能 # Bind the name getpass to the appropriate function try: import termios, TERMIOS except ImportError: try: import msvcrt except ImportError: try: from EasyDialogs import AskPassword except ImportError: getpass = default_getpass else: getpass = AskPassword else: getpass = win_getpass else: getpass = unix_getpass termios 是 UNIX 独有的一个模块,它提供了对于输入终端的底层控制。如果这个模块无效 ,则导入失败,Python 引发我们捕捉的 ImportError 异常。 OK,我们没有 termios,所以让我们试试 msvcrt,它是 Windows 独有的一个模块,可以提供在 Microsoft Visual C++ 运行服务中的许多有用的函数的一个API。如果导入失败,Python 会引发我们捕捉的 ImportError 异常。 如果前两个不能工作,我们试着从 EasyDialogs 导入一个函数,它是 Mac OS 独有的一个模块,提供了各种各样类型的弹出对话框。再一次,如果导入失败,Python 会引发一个我们捕捉的 ImportError 异常。 这些平台特定的模块没有一个有效 ,所以我们需要回头使用一个缺省口令输入函数 。注意我们在这里所做的:我们将函数 default_getpass 赋给变量 getpass。如果你读了官方 getpass 文档,它 会告诉你 getpass 模块定义了一个 getpass 函数。它是这样做的:通 过绑定 getpass 到正确的函数来适应你的平台。然后当你调用 getpass 函数时,你实际上调用了平台特定的函数,是这段代码已经 为你设置好的。你不需要知道或关心你的代码正运行在何种平台上; 只要调用 getpass,则它总能正确处理。 一个 try...except 块可以有一条 else 子句,就像 if 语句。 如果在 try 块中没有异常引发,然后 else 子句被执行。在本例中, 那就意味着如果 from EasyDialogs import AskPassword 导入可工作, 所以我们应该绑定 getpass 到 AskPassword 函数。其它每个 try...except 块有着相似的 else 子句,当我们发现一个 import 可用 时,就绑定 getpass 到适合的函数。 本文来自CSDN博客,转载请标明出处: 4.aspx 篇二 : 异常情况处理 1. 在11.5.10下的Responsibility “Inventory Vision Operation”, 若要切换组织到 V1. 需要设置如下: 方案:切换Responsibility 到 “Order Management Super User, Vision Operations”, 打开路径Inventory > Setup > Organiziton > Organization Access, 创建一行,填入: V1, Inventory, Vision Operations。()然后保存。 2. 打开库存会计期: 方案:Inventory > Accounting Close Cycle > Inventory Accounting Periods, select one period and change status. 打开总账会计期: 方案:General Ledger Super User -> Setup --> Open/Close Accounting Periods 3. 创建PO时, 提示PO Rev 已经存在: 方案:打开路径Purchasing > Setup > Organizations > Purchasing Options , 在”PO Number “ Generation处选择 Automatic. 4. 做Inter-Org transfer事务时,如果输入的Item不被认可,但 又确实存在. 方案:检查该item 是否已经分配到需要转移到的组织下。 5. 为有Serials属性控制的物料Pick Release时出错: total Serial number does not match transaction quantity. 方案:打开路径Inventory > Setup> parametsrs form,点击标签页Rev. lot...., 设置Allocate Serials为yes 6. 做接收时,为Purchasing period 打开GL date: 方案:Purchasing > Setup > Financials > Accounting > Control Purchasing Periods, 查找当前的 Fiscal Year, 然后设置该Period Status 为Open状态. 7. 执行一个SO的交货时, 提示错误: APP-QA-16134: You must enter results on the mandator collection plan: General Receiving 方案:打开菜单: tools > enter quality results 8. 做杂收时出现提示框:”Request Queued” 方案:打开System Profile表单, 设置如下的profile: 查找 TP%, 然后选择 “TP:INV Transaction processing mode”, 在 site层和用户层输入值 “On-line processing”. 9. 做杂收时提示需要Attribute: Error: Misc Rcpt: APP-FND-00828: Please enter the required context field value in the lot Attribute flexfield. The context field appears as one of the first segments in your flexfield. 方案:若要移除该限制,需要设置Descripitive Flex. 打开路径 Inventory->setup->Flexfield->Descriptive->Segments, 查找标题 “Lot Attribute%”, 然后去掉勾选 “Freeze Flexfield Definition”、”Required...”以及 “Display...”, 点击Segments按钮, 去掉 勾选 Enabled. 最后勾选 “Freeze Flexfield Definition”, 点击按 钮”Compile”. 或者 打开路径 Inventory->setup->Flexfield->Descriptive->Segments, 查 找标题 “Additional Line Attribute Information”, 去掉勾选 “Freeze Flexfield Definition”, 点击Segments按钮, 去掉勾选 Enabled. 最后勾 选 “Freeze Flexfield Definition”, 点击按钮”Compile”. 10. 做接收检验时,点击完按钮Inspection,出现的form名字 是 “Inspenct Details”, 而不是 “Enter Quality Results”. 或者出现错误 Error: APP-QA-16235: Quality Results cannot be entered because no Collection Plans apply. 方案:设置Profile: 查找用户MFG, 和profile QA:PO Inspection, 然后在Sizai”Oracle Purchasing”. 11. 做发运确认时, 出现错误: Actual departure date for stop M2- Boston:Boston is outside the current inventory period of organization W1 - Kansas City Distribution. 方案:打开库存会计期: Inventory > Accounting Close Cycle > Inventory Accounting Periods, 找到当前期间并打开. 12. 日期格式设置: 登录application,到Preferences 下,然后找到Regional下的日期格 式下拉框,选择需要的日期格式。 13. 做Order import时, 检查请求的输出, 发现错误”no order type”。 方案:打开路径 Purchasing > Setup > Organizations > Purchasing Options, 在Document Defaults下, Internal Requisition Order Type选择”Mixed”,然后保存. 14. 做Requisition import时, 出现接口方面的问题。 方案:首先检查 master item form里的”List price”属性值,若为空, 需要输入值. 15.做接收时,如果系统提示 GL date of Purcasing is inactive 方案:打开路径 Purchasing->Setup->Finacials->Accounting->Control Purchasing Periods,找到当前期间,打开。 16. Order Header / Order Line processing constraint 设置: Order Management > Setup > Rules > Security > Processing Constraints, 按 F11 进行查找,输入以下值: Applicaton = Order Management Entity = Order Line 然后按组合键 Ctrl + F11查找。然后查找相应的行项目,去掉对应 项目的勾选。 如果想查看processing constraint, 提交一个request: Processing Constraints Listing Report,设置参数: Entity = Order Line Operation = Cancel 17. 发运确认时,输入locator,出现错误: Enter value in segment Project before entering value in Task segment. 方案:若要移除该限制,需要设置 Key Flex. Inventory->Setup->Flexfield->Key->Segments, 查找Flexfield Title “%Stock Locator%”, 去掉勾选”Freeze Flexfield Definition”, 点击 Segments按钮, 去掉勾选Project 和 Task对应的 Enabled 复选框. 然 后勾选”Enable”和”Freeze Flexfield Definition” 复选框, 点击按钮 “Compile”. 18. 创建RMA 申请单时, 输入一行,弹出提示框: oe_order_lines_all flow_status_code in 37 what is flow about OM? 1 Entered 2 Booked:after booked,so line?s status is:Awaiting shipping,Ready to Release 3 release so:when release a so,items from subinventory1 to subinventory2 4 ship confirm:all released so line will be confirmed. 5 run the report “Workflow Background Process”,transfer data from om to ar interface table. after it done,so line is closed.when all so line is closed,the so header is closed. 6 ar autoinvoice 38 release so的时候,order line里的出货的schedule ship date必须修改为当天日期,然后在release so的窗口中设置schedule ship date的范围, 如果不设置,所有能出货的货物全部出货。 *********************************************************** ******************* 39 how to query view based client enviroment? begin apps.fnd_client_info.set_org_context; end; 最彻底的方案就是使用: begin fnd_global.APPS_INITIALIZE; end; ****************************************************************************** select * from OE_TRANSACTION_TYPES. all operation can be done within a SQL window. 40 in Discoverer,if a fold is from a database,every item will create a item class automatically,if a fold is from a custom SQL,it must be manually created a item class. 41 created_by -> fnd_user.user_id fnd_user.employee_id -> per_all_people_f.person_id 42 when ship confirm,the orders that only same delivery id can be deliveried together. 43 in OE menu,Order organizer is used to inquire some informations for orders,Sales Orders is used to create and change a order. 44 在OM里,45 once pick a release,every order line will create a delivery detail id from wsh_delivery_details table,but the release action will create only delivery name from wsh_new_deliveries 46 订单的最终状态: oe header,oe lines:closed delivery status:closed pick status:shipped transaction line status:interfaced 47 sales order number is numeric created by system automatically and purchase order number is character input manually. 48 in PO,when input and save a purchase order,the po header status is “incomplete” and change to “Approved” after it pass the approve.The PO number will be created automatically if no input po # manually. 49 After copying sales or purchase order,the new order is created and saved automatically. 50 how do create po and sales order number? purchase order number is created manually,sales order number is created automatically. 51 the po status is incompleted when it saved and change to approved after approved. 52 GL,AP,AR,INV,PO have own period,it must be open or close for every module.OM has no own period. 53 item在主组织进行录入,然后分配给库存组织使用。主组织 定义品号,库存组织打开会计期。库存组织不能定义新品号,但可以 查询。 54 pick release has two methods. 1: 修改或者录入so的时候scheduled ship date一定要填写适 当的日期,release so的时候输入确定的日期范围,范围内的so都被 release. 办法2:scheduled ship date不用输入具体日期,release so前先执行 Auto-Create deliveries,生成交货号,可以对多个so按Ctrl键同时选 择。路径:ship/transaction/Auto-create deliveries 55 employee information setup is on menu :Setup/Organizations/Employees,by INV Super User responsibility if HR module is absent. 56 直发订单,不需release so,ship confirm,但是需要做 autoinvoice 57 how is different between invoice and “收据”, it is by CUST_TRX_TYPE_ID ap:ap_invoices_all ar:ra_customer_trx_all 58 直发订单 生成直发so后,导入请购单,根据生成的请购单,再自动生成PO 59 in PO,Receiving>Receipts>Supplier and Internal为PO接收, Customers为客户退货 Receiving>Returns>Supplier and Internal为采购退货 60 internal company po and so,收货方,>发货方,>收货方,先 生成internal AR invoice,再生成internal company AP Invoice 61 出货单 由ra_customer_trx_all和ra_customer_trx_lines_all决定,line包含出货单物品内容。 装箱单:由oe_order_headers_all,oe_order_lines_all决定 组织: o.org_id = :P_org_id OR ol.ship_from_org_id = :P_org_id 内部订单:同普通订单,oe_order_headers_all,oe_order_lines_all,订单行加qp_list_lines.list_header_id=XXXXXX 请购单: po_requisition_headers_all, po_requisition_lines_all 62 oe_order_headers_all sold_from_org_id 与org_id对比,是否自身的订单,还是内部直发 sold_to_org_id ar_customer.customer_id ship_from_org_id warehouse_id 哪个仓库发货 ship_to_org_id ra_site_uses_all.site_use_id ship_to_location
/
本文档为【[异常处理]python异常处理】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索