Questions tagged as 'python'

1
answer

The time.sleep () with if / else declarations

Hello. I'm stuck. My goal is that if the user loads the enter or wait 2 seconds it starts the "PowerBIT" but in an if / else statement and I do not know how to do it. Example: #(...) elif machine == "" or #tempo: if temp >=20:...
asked by 09.07.2014 / 23:44
1
answer

Login on facebook with python

I would like, for educational reasons, to log into facebook with a python script. I tried the requests import requests s = requests.Session() post_url = 'https://www.facebook.com/login.php?login_attempt=1&lwv=110' headers = {"User-agen...
asked by 26.07.2016 / 21:51
2
answers

Scraping in Python - read pdf

I've done a scrapping in Python which takes a URL from any PDF, reads and returns, however in some PDFs I'm having the problem come with some characters like this:    ". \ nO \ xc3 \ xb3rg \ xc3 \ xa3o also \ xc3 \ xa9m discloses   result \...
asked by 19.09.2016 / 21:42
1
answer

Redeem dictionary key with maximum sum of respective value

I have the following dictionary: dic = {'bsx_8612': [23, 567, 632], 'asd_6375': [654, 12, 962], 'asd_2498': [56, 12, 574], 'bsx_9344': [96, 1022, 324]} I want to retrieve the key whose value has the largest sum of its elements. How I am doi...
asked by 24.06.2015 / 17:19
1
answer

Write to a CSV file

I need my script to write to a CSV file. The same will open a CSV file that has the column created_at (date and time), after that, the variable will be "broken" and will be written in a new CSV file the column day and time. However, it...
asked by 29.04.2017 / 17:18
2
answers

How to Direct Commands to Linux Terminal with Python

I need to create a script in Phyton that when run either by mouse click or 'enter' the keyboard, it opens the Linux terminal itself and executes any command inside it. I've already been able to get it to run the command, but as long as the scrip...
asked by 17.08.2014 / 21:42
1
answer

Why do these two ways of initializing the same list in Python generate structures of different sizes?

It is common to need to initialize a list in Python with a defined amount of elements and we can do this in two ways: 1) multiplying the list with one element by the desired quantity; or 2) use the list comprehensions technique.    Note:...
asked by 01.08.2018 / 02:50
1
answer

Copy a numpy.array without modifying the original

Given a numpy.array like the following: r = np.arange(36) r.resize(6, 6) That results in: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23], [2...
asked by 03.11.2016 / 23:38
3
answers

Why does not IDLE automatically stop running the program?

I think it's more out of curiosity. Unlike other IDEs, IDLE keeps the program "open" even after the end of its execution, while in other IDE's I need to put something like 'input ()' at the end so the program will not be terminated until I enter...
asked by 16.08.2014 / 15:13
1
answer

Understanding the pythonic way of dealing with properties

I'm trying to figure out how this python properties issue works. But the problem is that in all the net tutorials out there I only find the damn example with only one attribute. I'm looking for an example where you have more to do with day to da...
asked by 01.07.2015 / 01:56