0

I have written a program in Python, using version 3.3.3. This program is just a simple weight loss tracking program that uses a pictograph for visual representation of whatever number the user has input. The characters used in the pictograph are all unicode (□▪▫∙). I have used the open() function as follows:

open('Pictograph.txt', mode = 'a', encoding = 'utf8')

Prior to using open(), I was using tkinter's askopenfile() which would allow me to let the user choose which file they'd want to save to, but would not allow me to set the encoding to UTF-8. I finally stumbled upon the encoding option of open(), which works well, but only in the Python shell. (I was having problems writing those characters to a standard .txt file before this, encoding = 'utf8' made the difference for that problem, but did not help anything in the command line.)

Now, I have a 'help' option that enables the user to see a legend of the pictograph, and in so display cp1252 text, as well as the four Unicode characters listed above.

This is the message it displays for the femptosecond before it crashes

I just captured this image, but prior to that I felt it had to do with text encoding in the command line. Is there any way to allow my program to set the command line to where it can read those characters and not crash?

This is what is supposed to print (as seen in the shell):

enter image description here

Any insight would be greatly appreciated.


Okay, so this is a duplicate. That's it? I tried looking for an answer for over an hour. I didn't find anything that would solve my problem. I would like not to have to spend another hour trying to find the page I am supposedly duplicating.


Unicode characters in the Python CLI v2

Community
  • 1
  • 1
Ryan Prince
  • 27
  • 2
  • 7

0 Answers0