问题
I have the following script to import and export random TXT/CSV files from CLI, everything that passes has to be unique and case insensitive output in UTF-8, can I accomplish this with a set variable? I'm quite new to Python so every comment or suggestion is welcome!
This is my current script;
import hashlib
import sys
if len(sys.argv) < 3:
print("Wrong parameter; script | inputfile | outputfile")
sys.exit(1)
output_file_path = (sys.argv[2])
input_file_path = (sys.argv[1])
completed_lines_hash = set()
output_file = open(output_file_path, "w")
for line in open(input_file_path, "r")
hashValue = hashlib.md5(line.rstrip().encode('utf-8')).hexdigest()
if hashValue not in completed_lines_hash:
output_file.write(line)
completed_lines_hash.add(hashValue)
output_file.close()
来源:https://stackoverflow.com/questions/53780519/how-to-make-a-python-set-case-insensitive