Advertisement
khaiwen1111

Untitled

Feb 3rd, 2020
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Feb  4 01:07:40 2020
  4.  
  5. @author: Seow Khaiwen
  6. """
  7.        
  8. def split_string(string):
  9.     list_string = string.split(':')
  10.     return list_string
  11.  
  12. def join_string(list_string):
  13.  
  14.     string = '\n'.join(list_string)
  15.     return string
  16.  
  17. if __name__=="__main__":
  18.     f = open(r"D:\Users\abc.txt")
  19.     if f.mode=="r":
  20.         data=f.read()
  21.        
  22.     list_string=split_string(data)
  23.     new_string=join_string(list_string)
  24.     new_string_1=new_string.replace("1","one")
  25.     new_string_2=new_string_1.replace("2","two")
  26.     new_string_3=new_string_2.replace("3","three")
  27.     new_string_4=new_string_3.replace("'","")
  28.     new_string_5=new_string_4.replace("[","")
  29.     new_string_6=new_string_5.replace("]","")
  30.     print(new_string_6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement