python-2.x
Why does the division get rounded to an integer? [duplicate]
This question already has answers here: How can I force division to be floating point? Division keeps rounding down to 0?[详细]
2023-01-01 18:23 分类:问答How to force PyYAML to load strings as unicode objects?
The PyYAML package loads unmarked strings as either unicode or str objects, depending on their content.[详细]
2022-12-31 22:14 分类:问答In Python 2.x, using backticks to get decimal string from int object is Horrible?
In Python 2.x, using backticks to get decimal string from int object is Horrible? Because backticks are repr(), not开发者_Python百科 str()? I have noticed that when I answering this question.[详细]
2022-12-31 02:10 分类:问答Python Textwrap - forcing 'hard' breaks
I am trying to use textwrap to format an import file that is quite particular in how it is formatted. Basically, it is as follows (line length shortened for simplicity):[详细]
2022-12-30 16:01 分类:问答Reading binary data from stdin
Is it possible to read stdin as binary data in Python 2.6?If so, how? I see in the Python 3.1 documentation that this is fairly simple, but the facilities for doing this in 2.6 don\'t seem to be there[详细]
2022-12-30 08:31 分类:问答How to change the stdin and stdout encoding on Python 2
I\'m using Windows and Linux machines for the same project. The default encoding for stdin on Windows is cp1252, and on Linux it is utf-8.[详细]
2022-12-29 03:15 分类:问答Identifying that a variable is a new-style class in Python?
I\'m using Python 2.x and I\'m wondering if there\'s a way to tell if a variable is a new-style class? I know that if it\'s an old-style class that I can do the following to find out.[详细]
2022-12-27 17:16 分类:问答Command-line input causes SyntaxError
I have a simple Python question that I\'m having brain freeze on.This code snippet works.But when I substitue \"258 494-3929\" with phoneNumber, I get the following error below:[详细]
2022-12-26 12:29 分类:问答Why can't I pass self as a named argument to an instance method in Python?
This works: >>> def bar(x, y): ...print x, y ... >>> bar(y=3, x=1) 1 3 And this works: >>> class Foo(object):[详细]
2022-12-23 01:58 分类:问答How to organize Python modules for PyPI to support 2.x and 3.x
I have a Python module that I would like to upload to PyPI. So far, it is working for Python 2.x. It shouldn\'t be too hard to write a version for 3.x now.[详细]
2022-12-22 17:31 分类:问答