Questions tagged as 'python-3.x'

3
answers

JSON does not return utf-8

I'm using freegeoip to know my location and use it in my program, but when I make a call using: r = requests.get(location_url, headers={"content-type":"application/json;charset=UTF-8"}) The return looks like this: { ip: "0.0.0.0", cou...
asked by 10.07.2017 / 18:10
2
answers

Add a new value at the beginning of a pandas series

How do I add a new value to a pandas series? I made the copy of the dataframe series and now I need to add a new value to the swap_hoje series, however, instead of being at the end of the series, I need it to be at the beginning, at...
asked by 21.06.2017 / 18:51
1
answer

Why is the 'data' variable not defined?

Code: arquivo = open("surfing_data.csv") id_de_verificação = int(input("Insira a ID do surfista desejado: ")) def pesquisa_de_surfista(pesquisa): dados = {} for linha in arquivo: (ID, nome, pais, média, prancha, idade) = linha...
asked by 23.01.2017 / 23:14
1
answer

What happened to Unicode in Python 3?

I'm starting to use Python3 slowly. I was running a certain code that I used to run with Python2.7 and got the following error:    NameError: name 'unicode' is not defined So, I understand that unicode does not exist in Pyth...
asked by 23.11.2016 / 13:29
1
answer

Make different combinations of words within a sentence

As an example I have the following sentence: texto = O gato subiu no telhado de 10m, um homem jogou-lhe uma pedra e ele caiu de uma altura de 20m. I want to extract the following information: (O gato subiu 10m, O gato caiu 20m...
asked by 12.04.2017 / 22:17
1
answer

Why can not I pass a parameter to the class?

I'm trying to pass the "ink" parameter to the "Pen" class but I can not. I've tried using Boolean expressions instead of index, but still no results. Could someone give me a help ? class Caneta(): açao = 'escrever' def __init__(self...
asked by 02.10.2016 / 20:50
1
answer

Questions in Python (Try and except)

I am doing a program that calculates the grade of a simulated ENEM style of my school, I ask how many questions of each area the person has hit, however, I want to cause that if the person enters an invalid number in the second or third question...
asked by 04.09.2016 / 02:56
1
answer

Python: unsupported operand type (s) error for /: 'tuple' and 'int'

Hi, I have a problem with a function in Python, which involves a tuple of tuples. When executing this assembly function calling the tuple of tuples votes: votacoes = ( (0, 15729, 220408, 1297, 0, 3040, 993, 0, 1354, 1046, 0, 3284, 99652, 1...
asked by 08.11.2015 / 16:24
2
answers

ignore in function call if empty

suppose I'm feeding a function with a tuple: a = ['c:/', 'd:/', 'x:/', 'y:/'] b = ['c:/data', 'd:/data'] funcao((a, b)) however if you have a list that is empty you would like to ignore example: funcao((se_vazio_ignore(a), se_vazio_ignore...
asked by 25.07.2016 / 20:49
1
answer

Wrap strings using struct

I'm doing a basic exercise using the struct module, and I came across a problem: To wrap a string , we should enter in the struct.pack() method the number of characters it has, right? But what if this string is informe...
asked by 05.07.2015 / 05:36