list_one=[3,6,2,17,7,33,11,7] list_two=[1,2,3,7,4,2,17,33,11] list_new=list_one+list_two list=[] i=0 for x in list_new : if x not in list : list.append(x) list.sort() print list…
#第一个python实例:监控cpu #/bin/bash/env Python from __future__ import print_function from collections import OrderedDict import pprint def CPUinfo(): ''' Return the information in /proc/CPUinfo as a dictionary in the following format: CPU_info['proc0']={..…
# python实现合并两个文件并打印输出 import fileinput file_Path1 = input("请输入第一个合并文件:") file_Path2 = input("请输入第二个合并文件:") def demo_fileinput(fp1,fp2): with fileinput.input([fp1,fp2]) as lines: for line in lines: if fileinput.isfirstline(): print('\n=…
python中对两个 list 求交集,并集和差集: 1.首先是较为浅白的做法: >>> a=[1,2,3,4,5,6,7,8,9,10] >>> b=[1,2,3,4,5] >>> intersection=[v for v in a if v in b] >>> intersection [1, 2, 3, 4, 5] >>> union=b.extend([v for v in a]) >>>…