Python unicode popen or Popen error reading unicode

后端 未结 1 1818
执念已碎
执念已碎 2021-01-03 05:05

I have a program that generates the following output:

             ┌───────────────────────┐
             │10 day weather forecast│
             └───────────         


        
相关标签:
1条回答
  • 2021-01-03 05:33

    I'd say running your program from the console should work correctly because Python can guess the console encoding of the terminal window (cp437 on US Windows), but when run through a pipe Python uses the default of ascii. Try changing your program to encode all Unicode output to an explicit encoding, such as:

    print (upper_line * len).encode('cp437')

    Then when you read it from the pipe, you can either decode back to Unicode or print it directly to the terminal.

    0 讨论(0)
提交回复
热议问题