Questions tagged as 'python'

2
answers

How to access variables present in different functions?

What is the best way to access a variable that was created in a function? For example: def Luggage(): mala = [] take = raw_input("O que você deseja levar na sua viagem?") mala.append(take) If I wanted to access and use the ma...
asked by 24.01.2016 / 14:58
2
answers

Reading .CAP files efficiently with Python

I have some .CAP files that came from capturing packages with tcpdump. When trying to open with wireshark, the machine gets very slow, as I imagine it will try to load everything into RAM. I would like to write a program in Python to work mor...
asked by 01.03.2017 / 20:55
1
answer

How to divide two variables properly?

In the code below I try to divide the values, but I end up getting a completely wrong answer from the calculation: nota1 = input ("Digite a nota 1: ") nota12 = input ("Digite a nota 1: ") nota2 = input ("Digite a nota 2: ") nota22 = input ("D...
asked by 22.02.2017 / 23:01
1
answer

How do I use the if and else functions?

I have problems with the if and else functions, I started my programming studies very soon and I did not quite understand how to use them. Is it something like this? número = 2 If número == 2: Print("esse número é 2") Else: Pr...
asked by 02.02.2016 / 22:51
1
answer

Write index from a list in another list

T = [0,0,0,1,0,0,0,-1,0] def acoes(T): listaAction=[] for i in T: if(T[i]==0): listaAction.append(T.index(i)) return listaAction print(acoes(T)) How do I write list indexes that have value 0 in lis...
asked by 19.10.2017 / 11:53
1
answer

Remove duplicate dates by adding values

I need to remove the duplicate dates from the dataframe and add the values corresponding to those dates. I found an answer in the NA stack that is close to the one I need, but I could not shape it for my need: df.groupby('data', group_keys=...
asked by 21.06.2017 / 21:54
2
answers

Run script written in Python on windows (No python installed)

I have a script written in Python (3.6) that works normally if run on my PC (which has Python installed) My question is: If I run it on some other windows that do not have python installed, will it run normally? And if it does not work, is...
asked by 28.06.2017 / 00:36
1
answer

You can access the key by:

In dictionaries, in Python, is it possible to access a key through the value? Is there any method that invert key / value?     
asked by 29.04.2016 / 19:08
1
answer

Developing a BOT for polls with WordPress plugin Polldaddy

I tried to follow: link import requests dados ={"poll_id" : "9484127", "answer_id" :"43276282", "number_of_votes" : "1000"} url = "https://polldaddy.com/poll/9484127/" #while True: requests.post(url, data=dados) But it's still not vo...
asked by 31.07.2016 / 12:39
3
answers

Increment in Python list

Hello, I'm creating a script to do automatic machine logins. I created a list with several IPs that are the equipment that I want to access. I want to create a loop, tried with while and for, but I could not. Each lap in the loop it should...
asked by 08.07.2016 / 21:05