title: How to take data from a .txt list and save the result in another .txt?
body: <p>I don’t know the Python language, but I need to change this code:</p>
  
  <pre><code>#!/usr/bin/env python
  # https://en.bitcoin.it/wiki/Protocol_documentation#Addresses
  
  import hashlib
  import base58
  
  # ECDSA bitcoin Public Key
  pubkey = '02e026fdf8f48819c1d6a3711cd547d82cc9de5d5fed05316cdaeddddd503cf233'
  # See 'compressed form' at https://en.bitcoin.it/wiki/Protocol_documentation#Signatures
  compress_pubkey = False
  
  
  def hash160(hex_str):
      sha = hashlib.sha256()
      rip = hashlib.new('ripemd160')
      sha.update(hex_str)
      rip.update( sha.digest() )
      return rip.hexdigest()  # .hexdigest() is hex ASCII
  
  
  if (compress_pubkey):
      if (ord(bytearray.fromhex(pubkey[-2:])) % 2 == 0):
          pubkey_compressed = '02'
      else:
          pubkey_compressed = '03'
      pubkey_compressed += pubkey[2:66]
      hex_str = bytearray.fromhex(pubkey_compressed)
  else:
      hex_str = bytearray.fromhex(pubkey)
  
  # Obtain key:
  
  key_hash = '00' + hash160(hex_str)
  
  # Obtain signature:
  
  sha = hashlib.sha256()
  sha.update( bytearray.fromhex(key_hash) )
  checksum = sha.digest()
  sha = hashlib.sha256()
  sha.update(checksum)
  checksum = sha.hexdigest()[0:8]
  
  print ( "" + (base58.b58encode( bytes(bytearray.fromhex(key_hash + checksum)) )).decode('utf-8') )
  </code></pre>
  
  <p>Here need to take the public key data from the file list: <strong>Pubkey.txt</strong>
  and save the processed data to a new file: <strong>Results.txt</strong>
  Earlier, I saw scenarios in which data are taken from one text document, perform a function, and the result is stored in another text document.</p>