title: UnicodeDecodeError open python file with windows command prompt
body: <p>I have a script that called runsplit.py it looks like this:</p>
  <pre><code>import sys
  sys.stdout = open('final.txt', 'w')
  
  import re
  with open('a.txt') as f:
   new_split = [item.strip() for item in f.readlines()]
  
  for word in new_split:
   m = re.match(r&quot;(?:\{[^-#={}/|]+\})?(?:([^-#={}/|]+)-)?([^-#={}/|]+)(?:/[^-#={}/|]+)?(?:[#=]([^-#={}/|]+))?&quot;, word)
  if m:
      print(&quot;\t&quot;.join([str(item).lstrip() for item in m.groups()]))
  else:
      print(&quot;(no match: %s)&quot; % word)
  </code></pre>
  <p>and I have a text file called a.txt which I want to split in final.txt file but a.txt file has some characters like ⁱ and ǐ in it that made error when I run the script in command prompt the error said this:</p>
  <pre><code>File &quot;runsplit_in_terminal.py&quot;, line 9, in &lt;module&gt;
  print(&quot;\t&quot;.join([str(item).lstrip() for item in m.groups()]))
  File &quot;C:\Users\Sina\anaconda3\lib\encodings\cp1252.py&quot;, line 19, in encode
  return codecs.charmap_encode(input,self.errors,encoding_table)[0]
  UnicodeEncodeError: 'charmap' codec can't encode character '\x94' in position 10: character maps to 
  &lt;undefined&gt;
  </code></pre>
  <p>is there any advice to solve this issue thanks.</p>