Skip to content

Instantly share code, notes, and snippets.

@mzaini30
Created March 3, 2017 13:26
Show Gist options
  • Save mzaini30/2ebd6bdbe2c9187869d4401692ad7d8a to your computer and use it in GitHub Desktop.
Save mzaini30/2ebd6bdbe2c9187869d4401692ad7d8a to your computer and use it in GitHub Desktop.
Mengubah 2 spasi menjadi 1 tab
import re
lokasi = "/sdcard/python/regex tab/"
with open(lokasi+"/input.txt", "r") as file_input,\
open(lokasi+"/output.txt", "w") as file_output:
file_input = file_input.read()
file_input = re.sub(r" ", r"\t", file_input)
file_output.write(file_input)
print
print "done"
1. hdggsgdgsg
gegsggdgsvve
shebvsgsggd
2. hdggsgdvvdvsv
gegsggsgvsvd
dhshbwvevsv
1. hdggsgdgsg
gegsggdgsvve
shebvsgsggd
2. hdggsgdvvdvsv
gegsggsgvsvd
dhshbwvevsv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment