Most voted "python-2.7" questions
In the 2.x series of the Python programming language, version 2.7 is last and the latest. Use this tag only if the problem is specific to this version. Also use the [python] tag in your question.
Learn more…477 questions
Sort by count of
-
1
votes0
answers277
viewsDynamic python Python Dashboard
I am developing a project that requires a form to be created by the size of the amount of item that is created in another form. The initial form is the Formrota: class FormRota(forms.ModelForm):…
-
1
votes0
answers103
viewsPython I can’t import Recaptchafield
There’s a project that was sent to me that I’m going to work on. I created an Environment to move up the project and in the project had the requeriments where I surrounded it. But when executing the…
-
1
votes1
answer18
viewsDisplay a certain vector in a 2D list
I have the following problem: I have a 2D vector and wish to display only the first vector ([250, 27.65863337187866, 93.38094023943002, 27.65863337187866]). I wrote a code, but it’s showing…
-
1
votes1
answer513
viewsException handling (Try) error in python
I am making a program that makes numerical calculations, but constantly appear to me operations where there is division by 0 (zero). I ended up finding a solution using if, but still wanted to know…
-
1
votes1
answer932
viewsHow I create 2 Foms simultaneously Django
What I want is in a single templante bring these 2 Forms simultaneously, in separate pages works, but the two together still could not do. Do I need to make an intermediate form? Am I making a point…
-
1
votes1
answer2952
viewsTypeerror: list indices must be integers, not tuple
I have a code that calculates the Euclidean distance between two points. However, when executed it presents the error: "Typeerror: list indices must be integers, not tuple" I don’t know what I’m…
-
1
votes1
answer518
viewsCompare dates in an array?
In the date variable, you are receiving several dates in string as array, want to bring the smallest cont = 0 menor_data = datetime.strptime('31/12/2300', '%d/%m/%Y') while cont < len(datas):…
-
1
votes2
answers2098
viewsHandling of Python Network Settings
Working in linux environment, Python 2.7, and I am in need of a module/library in Python that allows me to change the network settings (IP, Subnet, Gateway and, if possible, primary and secondary…
-
1
votes2
answers712
viewsRename application in Django Admin
Good evening guys, I’m trying to rename the application in Django admin according to the documentation, but it ended up not happening, I think I’m doing something wrong, the code is as follows:…
-
1
votes1
answer148
viewsHow to create sublists with pairs of elements (x,y), in which the first of them (x) is in a sequence?
Friends, imagine a list of pairs of elements (x,y): lista = [(13, 38), (14, 35), (14, 36), (15, 33), (15, 34), (15, 35), (15, 36), (18, 31), (18, 32), (19, 33), (22, 34), (22, 29), (23, 30), (23,…
-
1
votes0
answers180
viewsSend Byte Command via socket to a python controller?
Hello guys I am trying to send commands to a Controller "Commbox", this controller has the objective to open and close gates, traffic lights and other things. I am able to send command in Java but I…
-
1
votes1
answer1336
viewsPython data extraction and automatic email sending with information obtained
Friends, The data extraction part is working and the email sending is also in part. I would like the same information that I print on screen and with the same formatting (skipping line etc)) to be…
-
1
votes3
answers691
viewsPython 3.6 regular expression for inteitra phrase extraction
I need to extract only the phrases that contain ADMINISTRATION - JUDGE OUTSIDE - NOCTURNE - SISU - GROUP B, for example. That is, I need to get only the name of the course, the city, the turn, the…
-
1
votes1
answer5762
viewsUnboundlocalerror: local variable 'adversario_1' referenced before assignment
I have the following code: def aleatorio(): from random import random a = random() return a def torneio(): canditado_1 = aleatorio() while canditado_1 <= 0.5: canditado_1 = aleatorio() if…
python-2.7asked 8 years ago Danilo 447 -
1
votes2
answers166
viewshelp with indentation that is generating error in python 3.6
I’m doing a webcrawler I’m having the following problem. I had to do a separate program to print out how many candidates passed each course. Only that the last line is not running, and it would make…
-
1
votes1
answer119
viewsHow to make a "time-Slice" in packages in a network dump with Python?
I’m trying to "grab" source Ips and target Ips inside a network dump (PCAP) file. The idea is to save all source Ips and all target IPS by scanning the file every 10 minutes ("time-Slice"), for…
-
1
votes1
answer2606
viewsHow to format float and range input in Python 2?
I need to make an average calculator (student grades) where the entries have a decimal place and are in the range [0, 10]. The exits need to present five decimal places and so far, with what I’ve…
-
1
votes2
answers159
viewsExtracting Window and Time values from a network dump
The following network dump (PCAP format file) is the result of capturing a denial of service attack in the laboratory: I would like to extract the time (Unix time) and the window value (win) and…
-
1
votes1
answer477
viewsWeb scraping at a specific url with Beautifulsoup
from bs4 import BeautifulSoup import requests import re url = 'http://www.bhaktiyogapura.com/2017/03/calendario-vaisnava-marco-de-2017/' header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64;…
-
1
votes1
answer229
viewsHow to get only one Json value using request.get_data() Flask Python
I’m a Python beginner and a hint to get only one value from the following Json. { "test1":"valortest1", "test2":"valortest2", "test3":"valortest3", "test1":"valortest1" } Use to get json as follows…
-
1
votes1
answer1118
viewsTypeerror: POST data should be bytes, an iterable of bytes, or a file Object. It cannot be of type str
I’m trying to translate a code from Python 2.7 to 3.6 Code 2.7 works perfectly: from urllib2 import Request, urlopen values = """ { "exchange_code": "PLNX", "exchange_market": "BTC/USDT" } """…
-
1
votes0
answers411
viewsError installing a library in Python 3.6 in windows
Good night. My question is very objective and direct. I’m trying to install a library in python 3.6 in windows 10 64 bits. However the following error is appearing : To install I am using Pip…
-
1
votes0
answers58
viewsConverting Python Web Scraper 2.7 to 3.5
Good afternoon, everyone! Here’s the deal: I found a script in Python 2.7 but I have version 3.6. As I am new in this field, I wanted to work manually to convert this script. Follow the code below:…
-
1
votes0
answers63
viewsI can’t install numpy
When calling a Python application appears written Traceback (Most recent call last): File "C: Users benev Onedrive programaþátio ML classificacao.py", line 15, in from sklearn.naive_bayes import…
-
1
votes1
answer249
viewsReuse of Python functions
I am a beginner in programming and I have the following situation: I have a class called TEST. Within this class has the function RANDOM. I have a second class called CHECK. Inside this class has…
python-2.7asked 7 years, 11 months ago Danilo 447 -
1
votes3
answers2758
viewsHow to print without line break in Python
matriz = [] def create_matriz(a, b): for contador in range(a): matriz.append( [0] * b ) def print_matriz(txt): cont = 0 for j in range(a): for i in range(b): if txt[cont] == "0": matriz[i][j] = 0…
-
1
votes2
answers1443
viewsHow to make a nested FOR?
I’m opening two files, one is a text, and the other is a list. I want through nested check how many times each item in the list appears in the text. I did so: arquivo = open('texto.txt', 'r') lista…
-
1
votes1
answer34
viewsSet CLASSPATH to be accessible in Apache
How do I for the environment variable CLASSPATH be accessible by apache? I have a Django project that uses the library python-weka-wrapper that bridges the Weka Java implementation. Everything works…
-
1
votes1
answer89
viewsRelation between Python Arrays
I’m a beginner in Python and I’m having a hard time doing the following: I have 1 vector with the following values: heading = [34.53, 32.64, 44.20, 43.41] These values are given by the Euclidean…
python-2.7asked 7 years, 9 months ago Danilo 447 -
1
votes1
answer3096
viewsHow to extract specific data from a Python text file?
I have a **text file of 49633 lines** (txt file) with the following format: -e Tue Mar 28 20:17:01 -03 2017 total used free shared buffers cached Mem: 239956 126484 113472 4904 10292 52280 -/+…
-
1
votes2
answers11713
viewsHow do I make python read line by line?
Let’s assume I have a txt file, with some data: [File.txt] Oie Olá Tudo bem? I want something (in python) that reads line by line and prints(print).
-
1
votes1
answer70
viewsCorrelating values in Python Arrays
I have a vector called POSITION, with the following values: position = [40.51, 30.52, 30.31] I have a vector called COORDINATES, with the following values: coordinates = [10, 20, 30, 40, 50, 60, 70,…
-
1
votes2
answers42
viewsIterate indexes of a vector
I have the following vector: a = [10, 20, 30, 40...] I need to create a new list that is the subtraction of the second index by the first, the third index by the first and so on... Then the third…
-
1
votes1
answer200
viewsBar chart made in Python became "weird". Any suggestions how to improve it?
Friends, The following chart was generated: The code used was the following: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime,…
-
1
votes1
answer810
viewsHow to keep a key press in pyautogui
I would like to keep a key pressed for x seconds. I know that pressing the button is: pyautogui.press("key") But how can I keep her pressed?
-
1
votes1
answer1294
viewsIs it possible to collect html source code using python?
I would like something in python, some library that could access the site and get its source code (HTML). Example: Talsite.com <h1>hello</h1> Is it possible for python to log into…
-
1
votes1
answer137
viewsScamming shorteners with python
I need for my project, some function using Python 2.7 enter a URL, and get the next URL from it. -> Example: goo.Gl/LAKFXG = / bit.ly/2D3SEnZ = / I don’t want to use the API of these URLS, but…
-
1
votes1
answer848
viewsDisplay only hours, minutes and seconds on a graph whose input is in Unix time
Be the Python code that generates a bar graph: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y = [] with…
-
1
votes1
answer95
viewsError in Python2
I’m practicing using Python 2, but I don’t know the reason for this error. Follow below my code with the error. And numpy and scipy are installed, because when I give the import no more error…
-
1
votes0
answers129
viewsI am unable to install scipy. this showing this error
Microsoft Windows [versão 10.0.14393] (c) 2016 Microsoft Corporation. Todos os direitos reservados. C:\Users\Aluno>pip install scipy Collecting scipy Using cached…
python-2.7asked 7 years, 7 months ago william jeferson 43 -
1
votes0
answers60
viewsHow can I use the Opencl functions available in Opencv?
I am creating a program in Python, which often ends up demanding more from the CPU and decided to research on how to use the GPU for processing. The Opencl databases I found had examples only in…
-
1
votes1
answer309
viewsReturn of python file read function
I did this snippet of code to read through a loop the contents of the list files. lista_nome_base_docs = ['a.txt', 'b.txt', 'c.txt'] tamanho = len(lista_nome_base_docs) print (tamanho)…
-
1
votes1
answer216
viewsSort 2D vector in descending order
I have the following vector: a = [['UK', 'FR', **numero**], ['UK', 'NL', **numero**], ['UK', 'PT', **numero**]] Where the variable number are floating point values and different. Wish to sort vector…
-
1
votes3
answers1839
viewsWeb scraping python running javascript on the CEF website
The CEF (Caixa Econômica Federal) changed the way it displays the results of the lotteries on its website, before I could get the results that all came in HTML via webscraping relatively easily…
-
1
votes2
answers1978
viewsHow to count the number of "Rows" in a python table
For example, I have a database called 123, in this database is the players table, which is where the players' accounts are. I want to count how many accounts there are in the database. Finally,…
-
1
votes1
answer28
viewsCross valdation n-fold
W1 W2 W3 W4 A/N 0 0.543405 0.278369 0.424518 0.844776 1 1 0.121569 0.670749 0.825853 0.136707 1 2 0.891322 0.209202 0.185328 0.108377 1 3 0.978624 0.811683 0.171941 0.816225 0 4 0.431704 0.940030…
-
1
votes1
answer2323
viewsWhat is the difference between Python versions 3.4, 3.5, 3.6, 3.7?
I thought Python only updated versions 2.7 to maintain compatibility but 3.x abandoned earlier versions. But he insists on updating versions 3.4, 3.5, 3.6, 3.7 constantly. What these various…
-
1
votes2
answers558
viewsImports into __init__.py file
I’m studying the documentation of Django and noticed that in some files __init__.py there are imports, I know the archive __init__.py defines a module but do not understand why imports in it.…
-
1
votes1
answer53
viewsHow to insert a line into a gnuplot py chart?
I want to insert a line in the middle of a graph I’m filling with Gnuplot (python),which will serve as Threshold, as for example in y = 0. How can I do this?
python-2.7asked 6 years, 8 months ago Bruno Santos 43 -
1
votes2
answers316
viewsProgram to ask multiplication questions
I intend to make a program in Python (2.7.14) that generates two numbers randomly (from 0 to 10), multiply them, ask the result for the user, and display whether the result is correct or wrong,…