Advertisements
The code was like this
# Create temp file
tempfile.tempdir = '/tmp'
temp, temp_name = tempfile.mkstemp()
if verbose:
print(temp_name)
os.write(temp,'Temporary file created by check_file_operations.py script for testing upload & download.\n')
os.close(temp)
While running it raised the following error.
TypeError: 'str' does not support the buffer interface
it was because of the buffer text. python 3, the socket accepts bytes, you need to convert string to bytes with a encode() function like this:
# Create temp file
tempfile.tempdir = '/tmp'
temp, temp_name = tempfile.mkstemp()
if verbose:
print(temp_name)
os.write(temp,'Temporary file created by check_file_operations.py script for testing upload & download.\n'.encode())
os.close(temp)
No comments:
Post a Comment
Be nice. That's all.