error because bytes are not able to be encoded?
So I am using this public program to parse this byte data, but I am getting the error that the "bytes" object I am parsing has no attribute 'encode' what is going on and how to I fix it?
62 for j in range(4):
63 b = f.read(1)
---> 64 b = b.encode('hex').upper()
65 tmpHex = b + tmpHex
66 tmpHex = ''
AttributeError: 'bytes' object has no attribute 'encode'
I have tried to replace encode with something else but I end up getting another error which is on line 65 above saying that b and tmpHex cannot be concatenated. How do I solve this?
I could not include all the code because stackoverflow said I had too much code and too little writing.
Link to full code is below:
https://github.com/normanvolt/blockchain-parser/blob/master/blockchain-parser.py
import os
import datetime
import hashlib
def HexToInt(s):
t = ''
if s == '':
r = 0
else:
t = '0x' + s
r = int(t,16)
return r
def reverse(input):
L = len(input)
if (L % 2) != 0:
return None
else:
Res = ''
L = L // 2
for i in range(L):
T = input[i*2] + input[i*2+1]
Res = T + Res
T = ''
return (Res);
def merkle_root(lst): # https://gist.github.com/anonymous/7eb080a67398f648c1709e41890f8c44
sha256d = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest()
hash_pair = lambda x, y: sha256d(x[::-1] + y[::-1])[::-1]
if len(lst) == 1: return lst[0]
if len(lst) % 2 == 1:
lst.append(lst[-1])
return merkle_root([hash_pair(x,y) for x, y in zip(*[iter(lst)]*2)])
dirA = 'd:/_blocks/' # Directory where blk*.dat files are stored
#dirA = sys.argv[1]
dirB = 'd:/_hash/' # Directory where to save parsing results
#dirA = sys.argv[2]
fList = os.listdir(dirA)
fList = [x for x in fList if (x.endswith('.dat') and x.startswith('blk'))]
fList.sort()
for i in fList:
nameSrc = i
nameRes = nameSrc.replace('.dat','.hash')
resList =
a = 0
t = dirA + nameSrc
resList.append('Start ' + t + ' in ' + str(datetime.datetime.now()))
print ('Start ' + t + ' in ' + str(datetime.datetime.now()))
f = open(t,'rb')
tmpHex = ''
fSize = os.path.getsize(t)
while f.tell() != fSize:
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Block size = ' + tmpHex)
tmpHex = ''
tmpPos3 = f.tell()
while f.tell() != tmpPos3 + 80:
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = tmpHex + b
tmpHex = tmpHex.decode('hex')
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = tmpHex.encode('hex')
tmpHex = tmpHex.upper()
tmpHex = reverse(tmpHex)
resList.append('SHA256 hash of the current block hash = ' + tmpHex)
f.seek(tmpPos3,0)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Version number = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('SHA256 hash of the previous block hash = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('MerkleRoot hash = ' + tmpHex)
MerkleRoot = tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Time stamp > ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Difficulty = ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Random number > ' + tmpHex)
tmpHex = ''
b = f.read(1)
bInt = int(b.encode('hex'),16)
c = 0
if bInt < 253:
c = 1
tmpHex = b.encode('hex').upper()
if bInt == 253: c = 3
if bInt == 254: c = 5
if bInt == 255: c = 9
for j in range(1,c):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
txCount = int(tmpHex,16)
resList.append('Transactions count = ' + str(txCount))
resList.append('')
tmpHex = ''
tmpPos1 = 0
tmpPos2 = 0
RawTX = ''
tx_hashes =
for k in range(txCount):
tmpPos1 = f.tell()
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('transactionVersionNumber = ' + tmpHex)
RawTX = reverse(tmpHex)
tmpHex = ''
I had to reduce the code because I had too much code and not enough details.
python byte
add a comment |
So I am using this public program to parse this byte data, but I am getting the error that the "bytes" object I am parsing has no attribute 'encode' what is going on and how to I fix it?
62 for j in range(4):
63 b = f.read(1)
---> 64 b = b.encode('hex').upper()
65 tmpHex = b + tmpHex
66 tmpHex = ''
AttributeError: 'bytes' object has no attribute 'encode'
I have tried to replace encode with something else but I end up getting another error which is on line 65 above saying that b and tmpHex cannot be concatenated. How do I solve this?
I could not include all the code because stackoverflow said I had too much code and too little writing.
Link to full code is below:
https://github.com/normanvolt/blockchain-parser/blob/master/blockchain-parser.py
import os
import datetime
import hashlib
def HexToInt(s):
t = ''
if s == '':
r = 0
else:
t = '0x' + s
r = int(t,16)
return r
def reverse(input):
L = len(input)
if (L % 2) != 0:
return None
else:
Res = ''
L = L // 2
for i in range(L):
T = input[i*2] + input[i*2+1]
Res = T + Res
T = ''
return (Res);
def merkle_root(lst): # https://gist.github.com/anonymous/7eb080a67398f648c1709e41890f8c44
sha256d = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest()
hash_pair = lambda x, y: sha256d(x[::-1] + y[::-1])[::-1]
if len(lst) == 1: return lst[0]
if len(lst) % 2 == 1:
lst.append(lst[-1])
return merkle_root([hash_pair(x,y) for x, y in zip(*[iter(lst)]*2)])
dirA = 'd:/_blocks/' # Directory where blk*.dat files are stored
#dirA = sys.argv[1]
dirB = 'd:/_hash/' # Directory where to save parsing results
#dirA = sys.argv[2]
fList = os.listdir(dirA)
fList = [x for x in fList if (x.endswith('.dat') and x.startswith('blk'))]
fList.sort()
for i in fList:
nameSrc = i
nameRes = nameSrc.replace('.dat','.hash')
resList =
a = 0
t = dirA + nameSrc
resList.append('Start ' + t + ' in ' + str(datetime.datetime.now()))
print ('Start ' + t + ' in ' + str(datetime.datetime.now()))
f = open(t,'rb')
tmpHex = ''
fSize = os.path.getsize(t)
while f.tell() != fSize:
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Block size = ' + tmpHex)
tmpHex = ''
tmpPos3 = f.tell()
while f.tell() != tmpPos3 + 80:
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = tmpHex + b
tmpHex = tmpHex.decode('hex')
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = tmpHex.encode('hex')
tmpHex = tmpHex.upper()
tmpHex = reverse(tmpHex)
resList.append('SHA256 hash of the current block hash = ' + tmpHex)
f.seek(tmpPos3,0)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Version number = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('SHA256 hash of the previous block hash = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('MerkleRoot hash = ' + tmpHex)
MerkleRoot = tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Time stamp > ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Difficulty = ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Random number > ' + tmpHex)
tmpHex = ''
b = f.read(1)
bInt = int(b.encode('hex'),16)
c = 0
if bInt < 253:
c = 1
tmpHex = b.encode('hex').upper()
if bInt == 253: c = 3
if bInt == 254: c = 5
if bInt == 255: c = 9
for j in range(1,c):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
txCount = int(tmpHex,16)
resList.append('Transactions count = ' + str(txCount))
resList.append('')
tmpHex = ''
tmpPos1 = 0
tmpPos2 = 0
RawTX = ''
tx_hashes =
for k in range(txCount):
tmpPos1 = f.tell()
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('transactionVersionNumber = ' + tmpHex)
RawTX = reverse(tmpHex)
tmpHex = ''
I had to reduce the code because I had too much code and not enough details.
python byte
Have you tried usingdecode()instead ofencode(), maybe?
– Green Cloak Guy
Nov 25 '18 at 4:24
when I do I get the following errorUnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 0: invalid start byte@GreenCloakGuy Referring to the same line which had the original error.
– SantiClaus
Nov 25 '18 at 21:14
add a comment |
So I am using this public program to parse this byte data, but I am getting the error that the "bytes" object I am parsing has no attribute 'encode' what is going on and how to I fix it?
62 for j in range(4):
63 b = f.read(1)
---> 64 b = b.encode('hex').upper()
65 tmpHex = b + tmpHex
66 tmpHex = ''
AttributeError: 'bytes' object has no attribute 'encode'
I have tried to replace encode with something else but I end up getting another error which is on line 65 above saying that b and tmpHex cannot be concatenated. How do I solve this?
I could not include all the code because stackoverflow said I had too much code and too little writing.
Link to full code is below:
https://github.com/normanvolt/blockchain-parser/blob/master/blockchain-parser.py
import os
import datetime
import hashlib
def HexToInt(s):
t = ''
if s == '':
r = 0
else:
t = '0x' + s
r = int(t,16)
return r
def reverse(input):
L = len(input)
if (L % 2) != 0:
return None
else:
Res = ''
L = L // 2
for i in range(L):
T = input[i*2] + input[i*2+1]
Res = T + Res
T = ''
return (Res);
def merkle_root(lst): # https://gist.github.com/anonymous/7eb080a67398f648c1709e41890f8c44
sha256d = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest()
hash_pair = lambda x, y: sha256d(x[::-1] + y[::-1])[::-1]
if len(lst) == 1: return lst[0]
if len(lst) % 2 == 1:
lst.append(lst[-1])
return merkle_root([hash_pair(x,y) for x, y in zip(*[iter(lst)]*2)])
dirA = 'd:/_blocks/' # Directory where blk*.dat files are stored
#dirA = sys.argv[1]
dirB = 'd:/_hash/' # Directory where to save parsing results
#dirA = sys.argv[2]
fList = os.listdir(dirA)
fList = [x for x in fList if (x.endswith('.dat') and x.startswith('blk'))]
fList.sort()
for i in fList:
nameSrc = i
nameRes = nameSrc.replace('.dat','.hash')
resList =
a = 0
t = dirA + nameSrc
resList.append('Start ' + t + ' in ' + str(datetime.datetime.now()))
print ('Start ' + t + ' in ' + str(datetime.datetime.now()))
f = open(t,'rb')
tmpHex = ''
fSize = os.path.getsize(t)
while f.tell() != fSize:
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Block size = ' + tmpHex)
tmpHex = ''
tmpPos3 = f.tell()
while f.tell() != tmpPos3 + 80:
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = tmpHex + b
tmpHex = tmpHex.decode('hex')
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = tmpHex.encode('hex')
tmpHex = tmpHex.upper()
tmpHex = reverse(tmpHex)
resList.append('SHA256 hash of the current block hash = ' + tmpHex)
f.seek(tmpPos3,0)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Version number = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('SHA256 hash of the previous block hash = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('MerkleRoot hash = ' + tmpHex)
MerkleRoot = tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Time stamp > ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Difficulty = ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Random number > ' + tmpHex)
tmpHex = ''
b = f.read(1)
bInt = int(b.encode('hex'),16)
c = 0
if bInt < 253:
c = 1
tmpHex = b.encode('hex').upper()
if bInt == 253: c = 3
if bInt == 254: c = 5
if bInt == 255: c = 9
for j in range(1,c):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
txCount = int(tmpHex,16)
resList.append('Transactions count = ' + str(txCount))
resList.append('')
tmpHex = ''
tmpPos1 = 0
tmpPos2 = 0
RawTX = ''
tx_hashes =
for k in range(txCount):
tmpPos1 = f.tell()
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('transactionVersionNumber = ' + tmpHex)
RawTX = reverse(tmpHex)
tmpHex = ''
I had to reduce the code because I had too much code and not enough details.
python byte
So I am using this public program to parse this byte data, but I am getting the error that the "bytes" object I am parsing has no attribute 'encode' what is going on and how to I fix it?
62 for j in range(4):
63 b = f.read(1)
---> 64 b = b.encode('hex').upper()
65 tmpHex = b + tmpHex
66 tmpHex = ''
AttributeError: 'bytes' object has no attribute 'encode'
I have tried to replace encode with something else but I end up getting another error which is on line 65 above saying that b and tmpHex cannot be concatenated. How do I solve this?
I could not include all the code because stackoverflow said I had too much code and too little writing.
Link to full code is below:
https://github.com/normanvolt/blockchain-parser/blob/master/blockchain-parser.py
import os
import datetime
import hashlib
def HexToInt(s):
t = ''
if s == '':
r = 0
else:
t = '0x' + s
r = int(t,16)
return r
def reverse(input):
L = len(input)
if (L % 2) != 0:
return None
else:
Res = ''
L = L // 2
for i in range(L):
T = input[i*2] + input[i*2+1]
Res = T + Res
T = ''
return (Res);
def merkle_root(lst): # https://gist.github.com/anonymous/7eb080a67398f648c1709e41890f8c44
sha256d = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest()
hash_pair = lambda x, y: sha256d(x[::-1] + y[::-1])[::-1]
if len(lst) == 1: return lst[0]
if len(lst) % 2 == 1:
lst.append(lst[-1])
return merkle_root([hash_pair(x,y) for x, y in zip(*[iter(lst)]*2)])
dirA = 'd:/_blocks/' # Directory where blk*.dat files are stored
#dirA = sys.argv[1]
dirB = 'd:/_hash/' # Directory where to save parsing results
#dirA = sys.argv[2]
fList = os.listdir(dirA)
fList = [x for x in fList if (x.endswith('.dat') and x.startswith('blk'))]
fList.sort()
for i in fList:
nameSrc = i
nameRes = nameSrc.replace('.dat','.hash')
resList =
a = 0
t = dirA + nameSrc
resList.append('Start ' + t + ' in ' + str(datetime.datetime.now()))
print ('Start ' + t + ' in ' + str(datetime.datetime.now()))
f = open(t,'rb')
tmpHex = ''
fSize = os.path.getsize(t)
while f.tell() != fSize:
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Block size = ' + tmpHex)
tmpHex = ''
tmpPos3 = f.tell()
while f.tell() != tmpPos3 + 80:
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = tmpHex + b
tmpHex = tmpHex.decode('hex')
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = hashlib.new('sha256', tmpHex).digest()
tmpHex = tmpHex.encode('hex')
tmpHex = tmpHex.upper()
tmpHex = reverse(tmpHex)
resList.append('SHA256 hash of the current block hash = ' + tmpHex)
f.seek(tmpPos3,0)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Version number = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('SHA256 hash of the previous block hash = ' + tmpHex)
tmpHex = ''
for j in range(32):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('MerkleRoot hash = ' + tmpHex)
MerkleRoot = tmpHex
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Time stamp > ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Difficulty = ' + tmpHex)
tmpHex = ''
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('Random number > ' + tmpHex)
tmpHex = ''
b = f.read(1)
bInt = int(b.encode('hex'),16)
c = 0
if bInt < 253:
c = 1
tmpHex = b.encode('hex').upper()
if bInt == 253: c = 3
if bInt == 254: c = 5
if bInt == 255: c = 9
for j in range(1,c):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
txCount = int(tmpHex,16)
resList.append('Transactions count = ' + str(txCount))
resList.append('')
tmpHex = ''
tmpPos1 = 0
tmpPos2 = 0
RawTX = ''
tx_hashes =
for k in range(txCount):
tmpPos1 = f.tell()
for j in range(4):
b = f.read(1)
b = b.encode('hex').upper()
tmpHex = b + tmpHex
resList.append('transactionVersionNumber = ' + tmpHex)
RawTX = reverse(tmpHex)
tmpHex = ''
I had to reduce the code because I had too much code and not enough details.
python byte
python byte
asked Nov 25 '18 at 4:18
SantiClausSantiClaus
17112
17112
Have you tried usingdecode()instead ofencode(), maybe?
– Green Cloak Guy
Nov 25 '18 at 4:24
when I do I get the following errorUnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 0: invalid start byte@GreenCloakGuy Referring to the same line which had the original error.
– SantiClaus
Nov 25 '18 at 21:14
add a comment |
Have you tried usingdecode()instead ofencode(), maybe?
– Green Cloak Guy
Nov 25 '18 at 4:24
when I do I get the following errorUnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 0: invalid start byte@GreenCloakGuy Referring to the same line which had the original error.
– SantiClaus
Nov 25 '18 at 21:14
Have you tried using
decode() instead of encode(), maybe?– Green Cloak Guy
Nov 25 '18 at 4:24
Have you tried using
decode() instead of encode(), maybe?– Green Cloak Guy
Nov 25 '18 at 4:24
when I do I get the following error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 0: invalid start byte @GreenCloakGuy Referring to the same line which had the original error.– SantiClaus
Nov 25 '18 at 21:14
when I do I get the following error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 0: invalid start byte @GreenCloakGuy Referring to the same line which had the original error.– SantiClaus
Nov 25 '18 at 21:14
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464619%2ferror-because-bytes-are-not-able-to-be-encoded%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464619%2ferror-because-bytes-are-not-able-to-be-encoded%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you tried using
decode()instead ofencode(), maybe?– Green Cloak Guy
Nov 25 '18 at 4:24
when I do I get the following error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 0: invalid start byte@GreenCloakGuy Referring to the same line which had the original error.– SantiClaus
Nov 25 '18 at 21:14