Bug with Python UTF-16 output and Windows line endings? -


इस कोड के साथ:

test.py

< पूर्व> import sys आयात कोडक sys.stdout = codecs.getwriter ('utf-16') (sys.stdout) प्रिंट "test1" प्रिंट "test2"

फिर मैं चला इसे:

  test.py & gt; Test.txt  

Windows 2000 में पायथन 2.6 में, मुझे पता चल रहा है कि बाइट अनुक्रम \ x0D \ x0A \ x00 पोस्ट-पाठ "itemprop =" text ">

इसे आज़माएं:

  import sys कोडेक आयात करें यदि sys.platform ==" win32 ": import os, msvcrt msvcrt.setmode (sys। Stdout.fileno (), osOININARY) वर्ग CRLFWrapper (ऑब्जेक्ट): def __init __ (स्वयं, आउटपुट): self.output = output def लिखना (स्वयं, s): self.output.write (s.replace ("\ n "," \ R \ n ")) def __getattr __ (आत्म, कुंजी): वापसी getattr (self.output, कुंजी) sys.stdout = CRLFWrapper (codecs.getwriter ('utf-16') (sys.stdout)) प्रिंट "Test1" प्रिंट "test2"  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -