
Lv.1
在 求大神回答tqdm高级的使用方法!急! 中回复
import difflib
from tqdm import *
a = open('/Users/harrisonalexander/Desktop/Jane Austen1.txt').read()
b = open('/Users/harrisonalexander/Desktop/Jane2.txt').read()
def compare():
result = difflib.SequenceMatcher(None, a, b).ratio()
return result
with tqdm(total=100) as pbar:
for i in tqdm(range(100)):
c = compare()
print(c)
你在 python里面直接打开的bcm文件应该是经过加密的,所以文件内容都是乱码和无关字符,不要直接读取,这样是无法进行文本比较的,新建一个txt文件夹,然后粘贴文字内容。用open打开。
2017-10-23T17:00:13 点赞:0
在 求大神回答tqdm高级的使用方法!急! 中回复
不要直接读取,这样是无法进行代码文本比较,建议,新建一个txt文件,然后粘贴上去,用open打开文件夹。
2017-10-23T17:21:05 点赞:0