14.12.11 00:38, Nick Coghlan написав(ла): > String translation is also an open question. For some codebases, you > want both u"" and "" to translate to a Unicode "" (either in Py3k or > via the future import), but if a code base deals with WSGI-style > native strings (by means of u"" for text, "" for native, b"" for > binary), then the more appropriate translation is to use the future > import and map them to "", str("") and b"" respectively. There are other place for native strings -- sys.argv. if sys.argv[1] == str('-'): f = sys.stdin else: f = open(sys.argv[1], 'r') Yet another pitfall -- sys.stdin is bytes stream in 2.x and text stream in 3.x. For reading binary data: if sys.argv[1] == str('-'): if sys.version_info[0] >= 3: f = sys.stdin.buffer.raw else: f = sys.stdin else: f = open(sys.argv[1], 'r') Reading text data is even more complicated in Python 2.x.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4