title: Error: time data "b'YYYY/MM/DD" does not match format '%Y/%m/%d' but it does
body: <p>I'm trying to parse dates from a textfile, but executing the scripts throws incorrect data format, when the format is correct.</p>
  
  <p>The file is a .txt file with the following structure</p>
  
  <p>2018/02/15 05:00:13 - somestring - anotherstring</p>
  
  <p>2018/02/15 05:00:14 - somestring - anotherstring</p>
  
  <p>2018/02/15 05:00:15 - somestring - anotherstring</p>
  
  <p>... etc</p>
  
  <p>The script gets the file divided in lines, and each line is divided on fields, of which one field is a date and time. I divided the date and the time in two separate fields, the time gets converted ok so the problem is in the date.</p>
  
  <p>This is what I get on execution:</p>
  
  <p>ValueError: time data "b'2018/02/15" does not match format '%Y/%m/%d'</p>
  
  <p>I noticed it prints the string with a "b" in front of it, which if I'm not mistaken it means it's a byte literal. I've tried using "decode("utf-8")" on it, but it throw's exception as "string" has no method decode. </p>
  
  <pre><code>#the file is in one long string as I get it from a 'cat' bash command via ssh
  file = str(stdout.read()) #reads the cat into a long string
  strings = file.split("\\n") #splits the string into lines
  for string in strings:
      fields = string.split(" - ")
      if len(fields) &gt;= 3:
          #dates.append(datetime.strptime(campos[0],"%Y/%m/%d %H:%M:%S")) #Wrong format
          datentime = fields[0].split()
          dates.append(datetime.strptime(datentime[0],"%Y/%m/%d")) #Wrong format
          print(datentime[1])
          dates.append(datetime.strptime(datentime[1],"%H:%M:%S")) #WORKS
  </code></pre>