Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
printing a ✔
#1
When running this code in my pycharm console it prints out the ✔.
print('✔')
But when I run it by clicking on the .py file, it prints out a question mark in a box. How do I fix this?
Reply
#2
How it appears will depend on who is displaying the output of your program. When I run it from the windows CMD or power shell I get the question mark because it doesn't know how to interpret the characters it is seeing. When I run it from IDLE I see the check mark because IDLE knows how to print the check mark.
Reply
#3
Yeah I want it to print the checkmark out in windows CMD. But how do i do that?
Reply
#4
The standard answer is "Do not write programs that output non-ANSI characters." If you want your program to work for everyone either you need to provide the terminal, or you need to write to the lowest common denominator. The windows CMD terminal (and probably power shell as well) only understand UTF-8. You cannot do anything to make your checkmark appear in those terminals.
Reply
#5
(Apr-16-2020, 02:59 PM)julio2000 Wrote: Yeah I want it to print the checkmark out in windows CMD. But how do i do that?
You can not as mention bye @deanhystad so can not cmder/Powsershell interpret the Unicode character.
Use better shell like cmder,i have not used cmder/Powsershell for several years,only for help sometime here in forum to show a similar look.
[Image: r8VsAe.png]
Reply
#6
But when I turn my program into an .exe. It won't work either right? cause that's just a command prompt
Reply
#7
It all depends on how it is run. If stdout (where printed characters go) goes to a terminal that understands how to print the checkmark, a checkmark will appear. If this is a program people will be running from CMD, they will see the question mark. If people run the program by double clicking the exe, they don't see anything, so it doesn't really matter.

If you turn this into a GUI application you don't have to worry about things like what terminal is used to run my program. That is a lot of work just to make a green checkmark appear, but it is something to consider.
Reply
#8
F :(

Thanks for your help tho!
Reply
#9
Yes you can print the tick mark. I have done it using python emoji model.
Reply
#10
To be fair the Unicode problem has noting to do with CMD or Powershell, but rather the terminal they are using. I just tried Windows Terminal from the Windows store that supports Unicode and it shows the checkmark when I run your program. Other than that I don't like it very much and it doesn't really fix your problem. There are plenty of terminals you could install that would work (I think), but unless the program is only for your own use I doubt you can convince your users to install additional software just to get a green checkmark.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020