title: How to import multiple jpg files from a folder and convert to string (base64)?
body: <p>I want to read/import all the image (jpg) files from a folder and convert these into Base64 one by one using some loop. I tried with the following code. But it doesn't show any result.</p>
  <pre><code>import os
  import base64
  directory = &quot;path&quot;
  files = os.listdir(directory)
  for file in files:
      if os.path.isfile(file):
          with open(os.path.join(file, 'rb')) as image_file:
          my_string = base64.b64encode(image_file.read())
          print(my_string)
  </code></pre>