37,721
社区成员
发帖
与我相关
我的任务
分享
#!/bin/python
import difflib
def main():
text1 = """http://www.vpsee.com is a website which is dedicated for
building scalable websites on cloud platforms. The keywords are: Linux, Mac,
Cloud Computing, C, Python, MySQL, Nginx, VPS, Performance, Scalability,
Architecture, ..., etc. Have fun!"""
text1_lines = text1.splitlines()
text2 = """http://VPSee.com is a website which is dedicated for
building scalable websites on cloud platforms. The keywords are: Linux, Mac,
Cloud Computing, C, Python, MySQL, Nginx, VPS, Performance, Scalability,
Programming, Optimisation, Architecture, ... , etc. Have fun !"""
text2_lines = text2.splitlines()
d = difflib.HtmlDiff()
with open("result.html", "w") as f:
for line in d.make_file(text1_lines, text2_lines):
f.write(line)
if __name__ == '__main__':
main()
diff=difflib.unified_diff(d1,d2,lineterm='')