GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python/diff.py at master · wallimht/python

Expand file tree

/

diff.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
44 lines (37 loc) · 1.24 KB
/

diff.py

Copy path

File metadata and controls

44 lines (37 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# _*_coding:utf-8_*_
import sys
import chardet
def get_list(file):
glist = list()
f = open(file, 'rb') # 先用二进制打开
data = f.read() # 读取文件内容
file_encoding = chardet.detect(data).get('encoding') # 得到文件的编码格式
with open(file, 'r', encoding=file_encoding)as f1: # 使用得到的文件编码格式打开文件
lines = f1.readlines()
for line in lines:
glist.append(line.strip())
return glist
def main():
list1 = get_list(sys.argv[1])
list2 = get_list(sys.argv[2])
on1 = set(list1).difference(set(list2)) # 只在list1中的
on2 = set(list2).difference(set(list1)) # 只在list2中的
public = set(list1).intersection(set(list2)) # 交集
print('只在%s中的: [%d]' % (sys.argv[1], len(on1)))
print('-------------->')
for i in on1:
print(i)
print('<--------------')
print('只在%s中的: [%d]' % (sys.argv[2], len(on2)))
print('-------------->')
for i in on2:
print(i)
print('<--------------')
print('public: [%d]' % len(set(public)))
print('-------------->')
for i in public:
print(i)
print('-------------->')
if __name__ == '__main__':
main()
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.