Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

How can I compare the differences between the two files(python Dictionary as a format)?

Use the python script to output the contents of the dictionary to a file , the file name is 2017-12-29.txt, the content of the file from output of dictionary content :

{u'AP1': [u'i-001',u'i-002'], u'AP2': [u'i-003', u'i-004'], u'AP3': [u'i-005', u'i-006'], u'AP4': [u'i-007', u'i-008'], u'AP5': ,[u'i-009', u'i-010']}

another file name is 2017-12-30.txt, the content of the file from output of dictionary content :

{u'AP1': [u'i-001'], u'AP2': [u'i-003', u'i-004'], u'AP3': [u'i-005'], u'AP4': [u'i-007', u'i-008'], u'AP5': ,[u'i-009', u'i-010',u'i-011']}

How can I compare the differences between the two files , then export this difference to another file in the dictionary format or other format ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Generate output files with pprint, run /usr/bin/diff -u or difflib against them, and you're done.

Oh, and do code this in python3. You'll be glad you did.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...