I have stored the string in a variable. And I want to append it to a text file. How can I achieve this?
def readyaml(abs_read_path,):
with open(abs_read_path, 'r') as stream, open("instanceinput.txt",'w') as fnew:
try:
content = yaml.load(stream)
instance = content['instance']
dump = instance[0]
print dump
fnew.write(dump)
except yaml.YAMLError as exc:
print(exc)
stream.close()
fnew.close()
readyaml(abs_read_path)