Sign in to follow this  

Python, writing to file

This topic is 3475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In order to write to my file mystring="mystring"; file.write(mystring); but it doesn't write the NULL char I believe. I need to write the NULL char as well due to the file format requirement. Do I have to do another file.write command to just write a 8 bit 0 value? What would the code look like?

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
In order to write to my file

mystring="mystring";
file.write(mystring);

but it doesn't write the NULL char I believe. I need to write the NULL char as well due to the file format requirement.
Do I have to do another file.write command to just write a 8 bit 0 value? What would the code look like?


You should be able to just add the NULL char at the end using the following
statement: mystring = "mystring\0"

Share this post


Link to post
Share on other sites

This topic is 3475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this