Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- автозапчасти лексус новосибирск
- автозапчасти лексус в туле
- запчасти для lexus ls 460
- разборка lexus rx
- запчасти на лексус rx 330 бу
- разборка lexus rx
- file ='C:\words.txt'
- uniqlines = set(open(file,'r', encoding='utf-8').readlines())
- gotovo = open(file,'w', encoding='utf-8').writelines(set(uniqlines))
- #!/usr/bin/env python3
- import sys
- import fileinput
- with fileinput.FileInput(inplace=True, backup='.bak', mode='rb') as file:
- seen = set()
- for line in file:
- if line not in seen: # first time
- seen.add(line)
- sys.stdout.buffer.write(line) # redirected to the file
- T:> python remove-duplicates-inplace.py C:words.txt
- for line in file:
- words = tuple(line.split())
- if words not in seen:
- seen.add(words)
- sys.stdout.buffer.write(line)
- #!/usr/bin/env python3
- from collections import OrderedDict
- filename = r'C:words.txt'
- with open(filename, encoding='utf-8') as file:
- uniq = OrderedDict.fromkeys(file)
- with open(filename, 'w', encoding='utf-8') as file:
- file.writelines(uniq)
- def delete_string():
- File = open('test.txt', 'r')
- str_list = []
- for i in File.readlines():
- if i not in str_list:
- str_list.append(i)
- File.close()
- File = open(a, 'w')
- for j in str_list:
- File.write(j)
- from tempfile import mkstemp
- from os import close, remove
- from shutil import move
- def write_lines(file='words.txt'):
- ft, temp = mkstemp()
- lines = []
- with open(temp, 'w') as t, open(file) as f:
- for line in f:
- if line not in lines:
- lines.append(line)
- t.write(line)
- close(ft)
- remove(file)
- move(temp, file)
- write_lines()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement