Perguntas com a marcação «python-3.x»

223
Divisão inteira do Python produz float

Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 2/2 1.0 Isso é pretendido? Lembro-me fortemente de versões anteriores voltando int/int=int? O que devo fazer, existe um novo...

220
builtins.TypeError: deve ser str, não bytes

Eu converti meus scripts do Python 2.7 para 3.2 e tenho um bug. # -*- coding: utf-8 -*- import time from datetime import date from lxml import etree from collections import OrderedDict # Create the root element page = etree.Element('results') # Make a new document tree doc =

196
Uso do Python "raise from"

Qual é a diferença entre raisee raise fromno Python? try: raise ValueError except Exception as e: raise IndexError que produz Traceback (most recent call last): File "tmp.py", line 2, in <module> raise ValueError ValueError During handling of the above exception, another exception...