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
-
3
votes3
answers4130
viewsGet X and Y from the screen using PYTHON
I want to create a bot(macro) that performs some click tasks, for this I am using the autopygui in python! But I don’t have much experience in X and Y, and testing it manually and boring. I would…
-
3
votes4
answers94
viewsPutting elements in lists
I would like to have two lists: one with the name of the fruit and the other with the colors. lista = ['banana [amarela]\n', 'uva [vinho]\n', 'laranja [laranjado]\n', 'kiwi [verde]\n', 'framboesa…
-
3
votes1
answer474
viewsProbabilistic Considerations on the Calculation of Shannon Entropy in a Network Traffic
Probabilistic Considerations on the Calculation of Shannon Entropy in a Network Traffic I have a dump file (CAP format) of a network traffic capture made with Debian tcpdump. Until a certain time,…
-
3
votes1
answer1886
viewsRemove whitespace from the Python list
I’m reading a file, stopwords.txt, and in this file each stopword is on a line, example: a o para Each stopword I am saving on a list as follows: with open(sys.argv[1],"r") as file_entrada:…
-
3
votes2
answers154
viewsFlask and its contexts
I’m new to the desenvolvimento Web and I’m studying FLask and it has some objects that should only be manipulated in certain context as the Flask.g and the Flask.current_app what I can’t understand…
-
3
votes1
answer2703
viewsHow to make crontab run a Python script
I’m trying to schedule a script I wrote in Python to run on crontab, But I can’t do it. The script is simple thing, it makes a telnet connection through the terminal and sends some commands. I…
-
3
votes2
answers434
viewsHow to create a counter in face detection?
As you can see in the code below, it only detects the faces with Haar Cascade, I would like to know how to display on the webcam the amount of people detected at the time. from __future__ import…
-
3
votes1
answer106
viewsClass definition within a function or another class
I’ve seen in some scripts definitions of classes within other classes or functions like this: class Grok(object): class Foo(object): ... ... What is the reason for this practice? It is only to not…
-
3
votes1
answer1217
viewsGrouping table groupby pandas
I have a table in this format User Material Nota 1 youtube 5 2 facebook 4 3 facebook 3 4 facebook 5 6 youtube 2 7 orkut 3 8 twitter 4 and would like to group so that in the final table shows only…
-
3
votes1
answer511
viewshow to import classes referencing each other in python?
I have a problem when it comes to importing classes into Python. See, there are 4 files: main: from classeB import ClasseB ClasseB() class A: from classeModelo import ClasseModelo class ClasseA():…
-
3
votes1
answer65
viewsPCA method for Feature Selection - How do I resolve the raise Exception("Data must be 1-dimensional" error)?
I am trying to implement the PCA method for Feature Selection from the following functions: #Função que permitirá rankear as features mais importantes em um barhplot def ranks_PCA (x_train, y_train,…
-
3
votes2
answers639
viewsGenerate random numbers in 2d numpy array without repeating Python
Good afternoon, I’m trying to generate a 2d numpy array without repeating numbers. My code: TAMANHO = 4 tabela= np.zeros((TAMANHO, TAMANHO), dtype = int) tabela[:, 0] = np.random.randint(1, 170,…
-
2
votes1
answer449
viewsBuild of Sublime Text 2 gives different result than ipython on the command line
I’m trying to migrate to Sublime Text 2 and do everything without leaving the program. Before I ran a script with the following line: from scipy.stats import beta, bernoulli, gaussian_kde In the…
-
2
votes1
answer119
viewsPage display error - Django
At Django I’m developing a Library project! (I’m Beginner at Django, I’ve never worked with web development) Summarizing I have in the file models.py a model Library and a model Book, in the model…
-
2
votes1
answer132
viewsImport Python Reportlab
Hello, I’m trying to import the following lib in my Python project 2.7: from reportlab.lib.rparsexml import simpleparse Error: Import: No module named reportlab.lib.rparsexml I tried to install the…
-
2
votes1
answer87
viewspython font error 2x
I am trying to create separate fonts for my project in a particular.py file, after creating them I care for the.py project, I do it this way as follows: py. """ Criando as fontes. """ def…
-
2
votes1
answer122
viewsAWS S3 Disabling Sslv3 Support
I received an email from AWS that basically says S3 will no longer support Sslv3. Then they listed the list of Buckets that are receiving requests on Sslv3 and one of my Buckets is production. The…
-
2
votes1
answer1017
viewsProduct of a function
Hi, I was wondering if there are any commands to perform the production of a function in Python. I’m creating a function to make the product of another function. def fx(a, v, t): return (…
-
2
votes1
answer55
viewsProblem Returning sh: 0: -c requires an argument
Good guys next, I have this code below for python 2.7: #!/usr/bin/env python # -*- encoding: utf-8 -*- import sys import os if len(sys.argv) <= 3: for comando in sys.argv[1:]: shell =…
python-2.7asked 9 years, 5 months ago GlaucioFonseca 317 -
2
votes0
answers76
viewsWorking with vectors
I need to generate a vector with 100 random number positions and see what the ratio of numbers 2 to every 10 vector positions, the first part I got, but not the rest, it helps? import random as rd…
-
2
votes1
answer63
viewsNameerror in get_special_folder_path
I did a little test in Python 2.X to try copying a file from the folder the script is in to the Windows startup folder: import shutil import sys, os startuplocation =…
-
2
votes1
answer702
viewsHow to separate each sequence of equal numbers from a string?
How do I split a number string? For example '233' to obtain ['2','33']. Given values may vary, for example '44446' and give ['4444','6'] or '2345' and give ['2','3','4','5']. That is, give split…
-
2
votes2
answers1278
viewsAdding consecutive integers to a list - Python
I have the following code: i = -0 soma = 0 lista = [1,2,3,4] for i in xrage(0,len(lista)): if lista[i] != lista[i+1]: soma += lista[i] i+=1 print soma You’re making the following mistake:…
python-2.7asked 8 years, 11 months ago João Angelo 23 -
2
votes3
answers4263
viewsParse Nfe XML in Python
I have the following code that aims to fetch a particular node of an XML Electronic Invoice, but without success. I tested with other Xmls and it worked. import xml.etree.ElementTree as ET tree =…
-
2
votes1
answer243
viewsInfinite loop in exercise using classes
I’m doing an exercise in Python, which is a game using classes. It happens that when it arrived in the room "Escapepod()" and I select the correct POD, the looping becomes infinite, not knowing the…
-
2
votes0
answers145
viewsInterface between python and Prolog
Good morning. I need to make the communication between Prolog and Python. I ended up finding a pySwip api that interface between these two technologies, but I can’t make it work because Prolog needs…
-
2
votes0
answers552
viewsSynchronization of threads in python
I am making a program that should simulate the synchronization of files between two threads, however, I do not know much the python language. I have already created the threads, lock methods and…
-
2
votes1
answer203
viewsPython - PHPSESSID
Well I’m trying to create a script who enters a website without having to log in through the library requests. I want to do it using the PHPSESSID. How can I do this?…
-
2
votes1
answer590
viewsPython -->Valueerror: incomplete format
Can someone help me with this code? I have two problems: The first is the error mentioned in the title and the second is the vector of the function, which does not receive attribution (when I went…
-
2
votes1
answer955
viewsMake 1 figure with 3 graphs
I have 3 functions like the following that allows to obtain each one a graph and I want a function where use the 3 graphs of the other functions to join in one figure. def funcao1(grafico): ...…
-
2
votes0
answers139
viewsRFID-RD522 with Python
Good morning guys!! I’m trying to connect a module RFID with PYHTON in the Raspberry B I followed the following tutorials:…
-
2
votes1
answer96
viewsGet exception name in Python where it is not specific
I’m using the exception Exception, but wanted to be more specific and take the correct exception, without the treatment the code returns me the following message: F: Bel Desktop…
-
2
votes1
answer556
viewsChange lag and height of Excel cell using xlwt
I need to change the height and width of the Excel cell I’m using the library xlwt. I can’t find any references, someone can help me?
-
2
votes1
answer212
viewsHow to include contents of a page . py on another page . py
How do I make a include or open a python page in another, for example in php: include 'content/filename.php'; Load Html it loads the file more .py no, I’ve tried the command open fp =…
-
2
votes1
answer865
viewsprint Qrcode directly Zebra printer by python
I am generating qrcodes by python, only that I want to print directly on zebra label printer, I can already print words contained in an entry, but when I try to print the error qrcode: code: def…
-
2
votes1
answer53
viewsDisplaying certain values in Python
I need help with the following: I have a variable that generates random integer numbers from (0 to 400). In a given number of executions, I wish(m) to be displayed(s) the value(s) and the…
-
2
votes2
answers176
viewsGenerate autoincrement serial number sequence
I want to generate a service order number, I have the code, but I want it to consult in the database the last number of the service order that was generated. Follows the code: def…
-
2
votes1
answer384
viewsIncrement a numeric string in 1
I want to add 1 to a counter that is represented as a string. the goal is to get the sequence of numbers later. For example: from 000570370 to 000570371. part of the code: def rangeOrdemServ(self):…
-
2
votes1
answer7101
viewsHow to read PDF
I am creating a script to grab a pdf and rewrite it in text. from StringIO import StringIO from slate import PDF from subprocess import Popen, PIPE, call import uuid #pego pdf existente url =…
-
2
votes2
answers1513
viewsCalculating Series in Python
How to calculate series in Python? I created an algorithm but I’m not getting to the final goal. Ex: S1 = x + (x-1) + (x – 2) + ... + (x – n) S2 = 1 + 1 +1 + 1 +2 + … 1 I entered with an initial…
python-2.7asked 8 years, 5 months ago Ramon Lopes 53 -
2
votes1
answer880
viewsCreate a Python list copy so that they are independent
I have the following situation: I have the list 1 with the following values [10,20,30,40]. I want to create a copy of this list, but I need the list_2 not to change when I modify some value of the…
-
2
votes1
answer2763
viewsImporting data using pandas in python
Good afternoon Personal! I am trying to import a csv file using the pandas package in Python import pandas as pd names_col = ['AnoInfracao', 'TrimestreInfracao', 'CodigoInfracao',…
-
2
votes2
answers323
viewsPython accumulator list
I am developing a function that takes 3 parameters fctn(Function, list, element) and that it has to return a list with the intermediate states of the accumulator, as in the example below:…
-
2
votes3
answers314
viewsHow to count the number of candidates on this page ? Python 3.6
Simple thing. I need to count how many candidates there are in the table of this page, for example : http://www.ufjf.br/cdara/sisu-2/sisu-2017-1a-edicao/lista-de-espera-sisu-3/?…
-
2
votes2
answers356
viewsChecking a Dos/Ddos attack (Denial of service) on a network dump (PCAP file)
from scapy.all import * import dpkt f1 = open("semAtaque.pcap") pcap = dpkt.pcap.Reader(f1) f1.close() f2 = open("Ataques.pcap") pcap = dpkt.pcap.Reader(f2) f2.close() I have two network traffic…
-
2
votes2
answers1631
viewsHow to install Numpy via PIP windows 7 64 bit
Good afternoon as I do to install Numpy via Pip. I downloaded Python 2.7.13 and do not know how to install via Pip.
-
2
votes2
answers811
viewsPrinting specific lines from a text file
Imagine that I have a text file called test.txt with the following content: 4 Março 2017- Sábado meu aniversario -prova de calculo 6 Março 2017- Segunda aniversario do Salomao - fazer compras 8…
-
2
votes1
answer322
viewsWhat’s wrong with my Python code?
I’m trying to create a simple project for study purposes but I’m having a hard time completing it. I’m using the library Pytube to download videos, I can download the videos but I can’t show the…
-
2
votes1
answer1506
viewsRunning external programs with Python
I would like to reduce the size of several Mp3 files in a directory with: ffmpeg -i k.mp3 -acodec libmp3lame -ac 2 -ab 16k -ar 44100 k_.mp3 where K is the name of the Mp3 (k from 1 to 8): I tried…
-
2
votes1
answer100
viewsCreate a 2D vector from a 1D vector in Python
I have a vector with the following values: a = [10, 20, 30, 40, 50, 60, 70, 80] I need to create 2D vector with these values. For example, it would have to look like this: b = [[10, 20], [30, 40],…