---
title: "python中list类型相减"
author: "standalone"
date: "2009-10-16T09:00:58Z"
tags: []
slug: "python-list"
draft: false
lastmod: "2009-10-16T09:00:58Z"
id: 491959
url: "https://standalone.iteye.com/blog/491959"
---

两个**list** ()类型相减  
就是比如  
a=\[1,2,3,4,5]  
b=\[2,3,4]  
a-b需要得到\[1,5]  
但是**python** **list** 不支持**减法**  
只能使用py的投机取巧了~ 呵呵  
我们来用set() 如下  
&lt;code l=**python** &gt;  
print **list** (set(a)-set(b))  
\[1,5] #结果