from hashlib import sha256
import csv
with open ('source.csv', 'r' ) as file:
reader = csv.reader ( file )
dic = {}
for hash in range ( 1000, 10000):
hasher = sha256 ( b'%i' % hash ).hexdigest ()
hash = dic [ hasher ] = hash
for row in reader:
name = row [ 0 ]
for key in row [ 1: ]:
hack = ( name, dic [ key ] )
for r in hack:
with open ( 'out.csv', 'w', newline = '' ) as out:
writer = csv.writer ( out )
writer.writerow ( hack )
我写的是:
peter,5104
写应该是这样的:
alex,2218
emma,4215
peter,5104