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
-
0
votes2
answers925
viewsHow to generate break condition of a repeat loop in Python during its execution?
I’m trying to make a program in Python that during the execution of a loop, some command is waiting for an input condition while the loop is executed. For example, a program that prints numbers in…
-
0
votes0
answers58
viewsHow to extract data for Models.py fields from Scrapy?
I intend to remove all "Municipios" from the tag starting on this page. https://www.anmp.pt/anmp/pro/mun1/mun101w3.php?cod=M2200 And then remove information such as: "name of the council", "mayor",…
-
0
votes1
answer35
viewsConnect a button with a pyqt4 lcd screen
Good afternoon, everyone! I need to develop a calculator in pyqt 4, but I don’t know how to connect the number/operations buttons to the virtual lcd display. I have already researched, but I haven’t…
-
0
votes1
answer69
viewsKeyboard condition
I am wanting to make a condition through the keys that the user press. For example, if it press 'ENTER' the script continues and press 'ESC' the script to. I searched the internet but found nothing…
-
0
votes1
answer64
viewsHow to change the content of a qLabel at runtime?
Good afternoon, you guys! I need each line of qLinedit to be numbered in ascending order from 1 to 24, I created a qLabel for this, but I don’t know how to make it change the numbering according to…
-
0
votes1
answer347
viewsAttributeerror: 'Directores' Object has no attribute
I am trying to get a value of a very simple class, but I have a problem that I cannot solve. Follow the codes below: Main class: from directores.directores import Directores # A classe Directores…
-
0
votes0
answers16
viewsArgument does not support iteration. How to resolve?
I am trying to apply zip to the x, y and z lists, but when running the program I get the following error: izip argument #1 must support iteration. Can someone help me fix my mistake? from…
-
0
votes1
answer220
viewsSelect column item in Python
I was able to filter the items I want, but they are in a kind of column. I did it that way: import os cmd = os.popen('arping -I enp1s0 -c 2 192.168.0.1') arr = cmd.read().split('\n') for line in…
-
0
votes1
answer61
viewsHow to sort items from a list using two different values?
I have a list, which contains several values, each group of values corresponds to an audio of a language, however I am not able to sort using two conditions. audio_list = [{640: 640, 'lang': u'en',…
-
0
votes0
answers47
viewsClientexception
Hello I am taking the error Clientexception and do not know why, I am long trying to tidy up and I keep taking the same error to upload my files (I use Sentry) code below: That’s the first message…
-
0
votes1
answer14
viewsManipulation and grid, hbox and Vbox in pyqt4
I’m a beginner and I’m doing a graphical interface with the help of pyqt4. I need to add two columns of buttons there where there’s only one, but every time I try, the button goes to the right and…
-
0
votes2
answers848
viewsProblem with balance of parentheses, in Python
Galera to with the following code: exp = str(input('Digite a expressão: ')) pilha = [] for simb in exp: if simb == '(': pilha.append('(') elif simb == ')': if len(pilha) > 0: pilha.pop() else: if…
-
0
votes1
answer1245
viewsHow to create a CSV file via Python by keeping the decimal separator in the same place?
I have a Python script that makes a request via API and saves the data in a CSV file. The data is stored in different lists in Python and should be saved in different columns in the CSV file. The…
-
0
votes1
answer69
viewsCreate multiple Dataframes through iteration
Is it possible to create multiple Dataframes within an iteration? I need to do this feat, follow the example: in the NUM iteration, it has numbers from 0 to 9, total 10 numbers. in the for nn in…
-
0
votes1
answer49
viewsPython command does not work
As you can see, I cannot access python from the terminal I’ve checked the system variables…
-
0
votes1
answer201
viewsFill in field with "00-00-0000" when empty
I am making a recording in the database (Postgresql) with Python, I use a base on .txt. Problem: At the base have some records are blank, and is giving error at the time of recording, occurs in the…
-
0
votes1
answer1361
viewsError "Valueerror: Length of value does not match length of index"
I’m trying to find the address of stores "5aSec" in Brazil, but I keep getting error when I run this code import requests import json import pandas as pd dMun =…
-
0
votes1
answer388
viewsRemoving duplicate lines
I’m developing my TCC, My TCC, it searches emails in google collection, makes bulk sending etc, I’m having a problem, In this search for emails he collects repeated emails and invalid emails, then…
-
0
votes1
answer208
viewsMake attachment system with my python email sender
So, I’m developing a mass mailing, Only I’m not getting to use attachment in this shipment. The Code is found like this: #!/usr/bin/python3 import smtplib import os as sistema import getpass…
-
0
votes1
answer99
viewsHow do you fix this code?
When I press the keyboard, for example the "w" to go forward, the robot goes forward and sometimes another motor turns on together. When I press a command and keep pressed, when stopping pressing…
-
0
votes1
answer19
viewsdtype error on file merge
I need to join several csv files, where the columns are float. I made a small code, but the output of the columns are in str, so I tried to add the output format of the data, but the following error…
-
0
votes1
answer72
viewsUnicodedecorror in "Pip upgrade" and "install pywinusb"
My experience in Python is not much, but no error of this kind had yet appeared in any installation. As always appeared the message to upgrade the version of Pip, I decided to continue with this…
-
0
votes2
answers136
viewsHow to do continuous firing in python?
Good afternoon. I am developing a project where I need to make two cameras to take sequences of photos and stop only after a pre-defined command. In my current code you need to decide the number of…
-
0
votes1
answer90
viewsExercise - Calculation of bhaskará
a=int(input("Digite o valor de A: ")) b=int(input("Digite o valor de B: ")) c=int(input("Digite o valor de C: ")) delta=float(((b**2)-4*a*c)) r1=float((-b +(delta ** (1/2))/2) r2=float((-b -(delta…
-
0
votes1
answer74
viewsHow to save peak detection outputs (Z-score algorithm) to a single file?
I would like the output of my program to be saved in a txt file with two columns, no parentheses. I tried to use a append (in the for, I believe on line 98 of the code) to join the outputs in a…
-
0
votes1
answer478
viewsAdding and sorting row of matrices in python
The program below generates a random matrix, according to the amount of lines desired. def gerar(nLins, nCols, min, max): from random import randint vals = [None] * nLins for i in range(nLins):…
-
0
votes1
answer637
viewsError running python script via python 2 terminal: "Ioerror: [Errno 2] No such file or directory:"
The program should create a mes/dia.dat file, but nothing is created and this error is returned to me, where we can see that the file is not being created with the file.open() command. Follow the…
-
0
votes1
answer45
viewsError outside the list range
I have a problem, I have 3 files that I need to open and get information from them, move to a list within the list (matrix?!) and compare information from 2 lists with another list to validate…
-
0
votes2
answers405
viewsIgnoring a line from a txt file
I read a file . txt where I want to separate each word by comma, ie when finding a space before the word and after. But I also need to ignore the entire txt line where the ##character is. Below…
-
0
votes1
answer69
viewsPython Type Error a float is required
When I print C1.getTotalDesconts() and C1.getSalarioLike() for some reason python is requiring a conversion to float, these methods always return int or float, I can’t imagine the reason for this…
-
0
votes1
answer126
viewscurve_fit: can’t Multiply Sequence by non-int of type 'numpy.float64'
I’m having trouble with the curve_fit of the scipy, the error that comes out tells me that it can’t multiply sequence by float, I’m trying to create a sequence based on the function I defined and…
-
0
votes1
answer697
viewsConvert PDF code string to arraybuffer/blob for client download
I’ve been having problems for a while, so I decided to ask here, because I’m already out of options. I’m getting a pdf of an api made in java. I get this pdf from the backend, in python, because I…
-
0
votes1
answer392
viewsLimit number of characters per Dataframe Python column
Need to limit the number of characters per column in Dataframe to Insert in SQL Server. Example: I have a Dataframe with 3 columns and 1k of rows (Column J/ K/ L) and I need to limit the Dataframe’s…
-
0
votes1
answer146
viewsRead binary file using struct created in C++
Good afternoon to all, I would like to read a binary file created in C++ using the following structure: struct STRUCT_MOB { char MobName[NAME_LENGTH]; // The name of the mob // 0 - 15 char Clan; //…
-
0
votes0
answers51
viewsPython ctypes ERROR: Exception: access Violation writing 0x00DEF6CC
I’m trying to import a dll C/C++ with the lib ctypes and use a function that it has internally, when passing the parameters to this function I always come across the error: ERROR: exception: access…
-
0
votes2
answers64
viewsHow to select methods in a function and add results in a list?
I’m trying with a function of this kind, which is in my main: if __name__ == "__main__": run_experiment(outros_parametros,['LA', 'RF', 'DT', 'ARD', 'PCA']) Cause only a few methods to be selected,…
-
0
votes1
answer89
viewsHow to read an array of arrays and save each array[ ] into a different variable to run function with barplot?
How can I read this array of arrays: [45 32 56 57 44 21 36 35 39 23 24 27 25 26 31 28 29 30 20 22 18 8 19 1 33 2 3 4 0 6 7 9 17 10 11 12 49 55 13 14 15 16 52 46 43 34 41 37 40 5 54 51 53 47 38 42 50…
-
0
votes1
answer113
viewsPython hangman
Guys, I’m playing a little python hangman game. My doubt is as follows: how do I order the hits according to the chosen word of the gallows and make it duplicate the letter I typed if there is more…
-
0
votes3
answers84
viewsCopy between strings inside Python lists
The operation consists of comparing two lists of strings, detecting which items are common and placing them in a certain order in a new list. The closest I got was: nova = [] lista = ['a', 'b', 'c',…
-
-1
votes1
answer220
viewsOpen python text set to apply functions (Len, set, colocations, etc.). Unicodedecorror
>>> import nltk >>> from nltk.corpus import PlaintextCorpusReader >>> meucorpus='C:\Users\dudu\Desktop\Artigos sem acentos' >>>…
-
-1
votes1
answer361
viewsConvert a string of numbers into a word
I need to do a function that receives a string composed of digits between 2-9 and that the output are letters, that is, basically the function will work as a keyboard of a mobile phone, where the…
python-2.7asked 9 years, 2 months ago Stagg 151 -
-1
votes1
answer73
viewslist indexes
My two initial lists have repeated values: B_I=[Cab, Bou, Bou, RFF, RF1, Rf2, Color] Ba_f=[Bou, Zez1, Zez2, Praca, Sro, Sro, Falag] I eliminated the repeaters, leaving with: Final=[Cab, Bou, RFF,…
-
-1
votes1
answer319
viewshelp with Qlocale and Brazilian currency format
in c++ I used to convert an integer value to the Brazilian currency format as follows: QLocale loc = QLocale::system(); QLocale brasil(QLocale::Portuguese);…
-
-1
votes1
answer1242
viewsPython - How to print multiple variables in a loop?
I’m collecting 7 different values through a while. Every time the while wheel, a value is assigned to the variable valor and is printado, but would like to save each valor in a variable for later…
-
-1
votes1
answer1178
viewsReading an XML file and printing specific fields using the Python language
I have the following XML file (actually it’s just a piece of the file): <!DOCTYPE sysstat PUBLIC "DTD v2.19 sysstat //EN" "http://pagesperso-orange.fr/sebastien.godard/sysstat-2.19.dtd">…
-
-1
votes1
answer916
viewsOrdering a list of strings in python
Staff need to sort a list that inside it there is another list containing exactly a string and a number, the problem is that I’m not getting the desired result, let’s put an example, if I have the…
-
-1
votes1
answer228
viewsPlotting circles in different planes
I need to plot circles in the plans Zy and zx, but I only get in the plane xy, because when changing the variables x, y and z, forgive the shape of a heart. How can I fix this? import numpy as np…
-
-1
votes1
answer882
viewsMysql + Python (Save Variable Login To Connect)
import the import getpass import mysql. class Acessdatabase(): UserName = "" PassWard = "" DataBase = "" def LoginDB(self): self.UserName = input("Username: ") os.system("cls") self.PassWard =…
-
-1
votes1
answer337
viewsIncrease Spirograph Loop Speed in Turtle
Using these references: Spirograph Patterns and python 3.4 Spirograph error the following code has been created: Code import turtle import math import random def Xcord(R,r,p,t): return (R-r) *…
-
-1
votes1
answer260
viewsTransfer the value of a variable to Ctrl+C in Python?
I’m doing a job and need the value of a variable to go to the Clipboard so I can use it at another time. You can do this in Python v2.7?