Professional Documents
Culture Documents
Function Write
Function Write
Function: write
Function Prototype
Note
Parameter Description
Return Value
Error Handling
Example
Result
This function enables you to write data into the opened file.
Function Prototype
File_object.write(str)
Note
When using the Write function, you need to open the existing file in a read mode through the
Open function.
When the file is opened in a 'w' or 'w+' mode, the written data overwrites the original data of
the file. When the file is opened in an 'a' or 'a+' mode, the written data is appended to the end
of the file.
Parameter Description
Parameter Description
Return Value
None
Error Handling
None
https://10.98.117.5:31943/hedex/hedex.do?lib=OMC&id=omc.Scriptapp.mainpage&topicid=p_write_file_a&locale=en-us 1/2
3/25/23, 4:09 PM Function: write
Example
fp = Open("Hello.txt",'w')
str = "12345"
fp.write(str)
fp.close()
fp = Open("Hello.txt",'r')
read_str = fp.read()
fp.close()
Print(read_str)
Result
12345
https://10.98.117.5:31943/hedex/hedex.do?lib=OMC&id=omc.Scriptapp.mainpage&topicid=p_write_file_a&locale=en-us 2/2