user57563: I am aware how to convert the private key into WIF format in python, now I am trying to reverse this process and convert a WIF formatted private key back into a 256-bit private key, following this guide: https://en.bitcoin.it/wiki/Wallet_import_format
This is the code to convert from 256-bit private key into WIF format:
import hashlib
import base58
import binascii


private_key_static = "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D"
extended_key = "80"+private_key_static
first_sha256 = hashlib.sha256(binascii.unhexlify(extended_key)).hexdigest()
second_sha256 = hashlib.sha256(binascii.unhexlify(first_sha256)).hexdigest()

# add checksum to end of extended key
final_key = extended_key+second_sha256[:8]

# Wallet Import Format = base 58 encoded final_key
WIF = base58.b58encode(binascii.unhexlify(final_key))

print (WIF)

Now my attempt to reverse this process looks like this:
import hashlib
import base58
import binascii

private_key_WIF = 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ
first_encode = base58.b58decode(binascii.hexlify(private_key_WIF))
print (first_encode)

Instead of receiving the byte string, I get following error: 
TypeError: a bytes-like object is required, not 'str'

(All private keys used are sample keys taken from Bitcoin Wiki.)

user48884: Don't do this: binascii.hexlify(private_key_WIF). That's not how you use binascii.hexlify. There is no hex here, and the string is not a bytes-like object. private_key_WIF is just a string. You want to pass that string directly into base58.b58decode because you want to decode the WIF (which is base58).

user63624: converts WIF private key back to basic private key format
import hashlib
import base58
import binascii

private_key_WIF = input("WIF: ")
first_encode = base58.b58decode(private_key_WIF)
private_key_full = binascii.hexlify(first_encode)
private_key = private_key_full[2:-8]
print(private_key)


57563: <p>I am aware how to convert the private key into WIF format in python, now I am trying to reverse this process and convert a WIF formatted private key back into a 256-bit private key, following this guide: <a href="https://en.bitcoin.it/wiki/Wallet_import_format" rel="noreferrer">https://en.bitcoin.it/wiki/Wallet_import_format</a></p>

<p>This is the code to convert from 256-bit private key into WIF format:</p>

<pre><code>import hashlib
import base58
import binascii


private_key_static = "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D"
extended_key = "80"+private_key_static
first_sha256 = hashlib.sha256(binascii.unhexlify(extended_key)).hexdigest()
second_sha256 = hashlib.sha256(binascii.unhexlify(first_sha256)).hexdigest()

# add checksum to end of extended key
final_key = extended_key+second_sha256[:8]

# Wallet Import Format = base 58 encoded final_key
WIF = base58.b58encode(binascii.unhexlify(final_key))

print (WIF)
</code></pre>

<p>Now my attempt to reverse this process looks like this:</p>

<pre><code>import hashlib
import base58
import binascii

private_key_WIF = 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ
first_encode = base58.b58decode(binascii.hexlify(private_key_WIF))
print (first_encode)
</code></pre>

<p>Instead of receiving the byte string, I get following error: </p>

<pre><code>TypeError: a bytes-like object is required, not 'str'
</code></pre>

<p>(All private keys used are sample keys taken from Bitcoin Wiki.)</p>
 48884: <p>Don't do this: <code>binascii.hexlify(private_key_WIF)</code>. That's not how you use <code>binascii.hexlify</code>. There is no hex here, and the string is not a bytes-like object. <code>private_key_WIF</code> is just a string. You want to pass that string directly into <code>base58.b58decode</code> because you want to decode the WIF (which is base58).</p>
 63624: <h1>converts WIF private key back to basic private key format</h1>
<pre><code>import hashlib
import base58
import binascii

private_key_WIF = input(&quot;WIF: &quot;)
first_encode = base58.b58decode(private_key_WIF)
private_key_full = binascii.hexlify(first_encode)
private_key = private_key_full[2:-8]
print(private_key)
</code></pre>
