def save_py_data_struct(filename, data):
 dirname = os.path.dirname(filename)
 if (not os.path.exists(dirname)):
  os.makedirs(dirname)
 if is_py2:
  import codecs
  f = codecs.open(filename, 'w', encoding='utf-8')
 else:
  f = open(filename, 'w', encoding='utf-8')
 with f:
  pprint.pprint(data, f)

def save_py_data_struct ( filename , data ) : dirname = os . path . dirname ( filename ) if ( not os . path . exists ( dirname ) ) : os . makedirs ( dirname ) if is_py2 : import codecs f = codecs . open ( filename , 'w' , encoding = 'utf-8' ) else : f = open ( filename , 'w' , encoding = 'utf-8' ) with f : pprint . pprint ( data , f )
save data into text file as python data structure .