so i have variable contains in bytes and i want to save it to str. but how to do it? i tried various kinds of ways, but always got error
'utf-8' codec can't decode byte 0xa0 in position 0: invalid start byte
i want to save the result encrypt file to text file. so i have the proof it the file was encrypt. here;s my ways 1:
 def create_file(f):
     response = HttpResponse(content_type="text/plain")
     response['Content-Disposition'] = 'attachment; filename=file.txt'
     filename = f
     print(filename)
     name_byte = codecs.decode(filename)
     print(name_byte)
     return response
my ways 2 :
def create_file(enc):
    with open("file.txt", "w", encoding="utf-8") as f:
        enc = enc.decode('utf-8')
        f.write(enc)
my ways 3:
def create_file(f):
    file = open("file.txt", "w")
    f = f.decode('utf-8')
    download = file.write(f)
    file.close()
    print(download)
    return download
f = b'\xa0\x0e\xdc\x14' f is the return result of encrypt
i called the function :
#in views
download = create_file(enc)
           print(download)
#in urls
path("create_file", views.create_file, name="create_file"),
#in html
<a href="{% url 'create_file' %}">
 
     
    
