如果在Python中元组可以为空,如何通过最后一个元素对元组列表进行排序?(How to sort list of tuples by the last element if tuples can be empty in Python?)
需要通过最后一个元素对元组列表进行排序,元组可以是空的。 如果元组不为空,我知道如何排序:
sorted(lst, key=lambda p: p[-1]);
但是当列表有
()
:IndexError: tuple index out of range
。我无法找到如何避免它。
Need to sort a list of tuples by the last element, tuples can be empty. I know how to sort if tuples are not empty:
sorted(lst, key=lambda p: p[-1]);
But when list has
()
:IndexError: tuple index out of range
.I couldn't find how to avoid it.
原文:https://stackoverflow.com/questions/46463373
最满意答案
正如Arya所说,您需要更新crm_helpdesk模块。 加载更改。如果您的修改进入
<data noupdate="1">...</data>
请在新数据库中检查它,或将noupdate =“1”更改为noupdate =“0”。 并更新它。然后再次更改为noupdate =“1”As Arya told, You need to update the crm_helpdesk module. to load the changes.if your modifications comes under
<data noupdate="1">...</data>
then check it in new database or change noupdate="1" to noupdate="0". and update it.After that again change to noupdate="1"
相关问答
更多-
在openerp中对齐字段(Align field in openerp)[2022-08-21]
在.py文件中试试这个 class cus(osv.osv): _name = "lis.lab" _description = "This table is for keeping lab data of cord blood" _columns = { 'name': fields.char('Lab Id',size=64,required=True), 'excutive_name': fields.char('Excutive Name', size=64), 'date_ ... -
正如Arya所说,您需要更新crm_helpdesk模块。 加载更改。如果您的修改进入...请在新数据库中检查它,或将noupdate =“1”更改为noupdate =“0”。 并更新它。然后再次更改为noupdate =“1” As Arya told, You need to update the crm_helpdesk module. to load the changes.if your modifications comes under您必须在.js文件中编写代码并将其放在自定义模块中。 这是我创建的脚本。 当光标位于日历中的事件上时,它会创建一个框: 在myModule / static / js / test.js文件中: $(function() { $( document ).tooltip({ items: ".dhx_cal_event, .dhx_cal_event_line, .dhx_cal_event_clear", open: function( eve ...您必须执行数据迁移。 这不是一件容易的事。 您可以使用以下某些迁移工具: OpenUpgrade 。 或者您可以使用一些ETL工具,如Odoo ETL 如果您只想迁移某个表,可以将其导出为CSV文件,然后在Odoo中导入它,选择正确的列。 You must do a data migration. That's not an easy task. You can use some of this migration tools: OpenUpgrade. Or you can use some ETL to ...请参阅下面的链接。 我需要的是这里给出的。 http://pysvn.tigris.org/docs/pysvn_prog_ref.html http://pysvn.tigris.org/docs/pysvn_prog_guide.html Refer these links below. what I need is given here. http://pysvn.tigris.org/docs/pysvn_prog_ref.html http://pysvn.tigris.org/docs/pysv ...使用XML-RPC非常类似于直接在服务器上工作,只是速度较慢。 要获取产品列表,您需要与product.product进行交互,并缩小列表(和数据),您需要指定domain ,如domain=[('color','=','red'),('style','=','sport')]和fields=['id','name','...'] 。 希望这足以让你前进。 Working through XML-RPC is pretty much like working directly on the server, ...您必须使用有效数据访问它。 Common( xmlrpc/common )用于连接目的,Object( xmlrpc/object )用于访问表和函数(模块)。 为此,您可以使用Python,PHP,Java等创建api 例如,检查此链接 You have to access it with valid data. Common (xmlrpc/common) is for connection purposes and Object (xmlrpc/object) is to access tables ...更新您的xml,因为您已在product.specification对象中添加了字段,因此您必须在模型中定义它。 并继承对象中的product.product意味着您可以访问product.specification对象中product.product的所有字段。
... 安装ODOO8(OPENERP)(Installing ODOO8 (OPENERP))[2022-04-24]
你错过了一个图书馆。 使用pip,apt-get或任何其他方式安装它来安装它。 你可能需要sudo才能安装软件包。 apt-get的 apt-get install python-qrcode 果仁 pip install qrcode You're missing a library. Install it with pip, apt-get or any other way to install a package. You'll probably need sudo to install the pa ...OpenERP安装问题(issues with OpenERP installation)[2022-07-24]
此错误表示OpenERP正在尝试使用“ghrix”用户连接到PostgreSQL数据库服务器,该用户不存在。 这可能是您启动服务器的用户。 如果您为OpenERP创建了一个特殊的数据库用户,则需要使用--db_user=DB_USER在命令行中指定它(在这种情况下,您可能还需要--db_host=localhost和--db-password=YOUR_PASSWORD )。 如果您还没有创建任何数据库用户,最简单的解决方案可能是创建一个名为ghrix ,例如: $ sudo su - postgres $ ...相关文章
更多- Python 列表(list)操作
- Hadoop 之 Secondary Sort介绍
- Python内建函数(A)
- Hadoop实现Secondary Sort
- java List排序一
- python2和python3的区别
- 【转帖】Python 资源索引
- Linux中sort用法(转)
- Python资源索引 【转载】
- python字典操作
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)