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
votes1
answer3728
viewsLogarithmic Scale Graph with Python
Initially I created a Values X tempo (Unix Time) chart with the following code: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import…
-
0
votes0
answers25
viewsChanging vector-specific positions, determining random and equal values
I have the following vector: [**17, 17**, 1954, 909, **17, 17**, 411, 844, **17, 17**, 1954, 909, **17, 17**, 411, 844] As noted, the indices [0,1]; [4,5]; [8, 9] and [12, 13] are equal. I need to…
-
0
votes3
answers1276
viewscode to return divisors and compare common ones
I am trying to create a code that returns the common divisors between 2 variables that receive integer numbers. And then show the common divisors. To return me the splitters I am using this code for…
-
0
votes1
answer1006
viewsHow to run Python scripts with . txt entry in Windows?
Hello, I’m a beginner here at Stack Overflow and in Python, and I need help to run a file of my class, whose entry is written a file. txt. I know that in the Linux terminal, for Python 2.7, the…
python-2.7asked 7 years, 1 month ago anajbellini 3 -
0
votes0
answers91
viewsHow do I install the Discord.py library in the unbutu terminal?
How do I install the Discord.py library in the unbutu terminal? Discord is already installed, I want to install the library now, through the terminal.
-
0
votes1
answer26
viewsGet content from email
I’m using the following: import imaplib import email m = imaplib.IMAP4_SSL("imap.gmail.com", 993) m.login("myemail","mypass") m.select("Inbox") result, data = m.uid('search', None, "ALL") # search…
-
0
votes1
answer635
viewsPython: Error translating text with the Translate api
I’m trying to do a translation with the Googletrans api(https://pypi.org/project/googletrans/). Code: # -*- coding: utf-8 -*- from googletrans import Translator translator = Translator() print…
-
0
votes1
answer45
viewsIdentifying the most effective method of identifying the central element of a matrix
I have the following algorithm: import numpy as np matriz = np.array(np.zeros(81).reshape(9, 9)) for i in range(1, matriz.shape[0], 3): for j in range(1, matriz.shape[1], 3): matriz[i, j] = 255…
-
0
votes2
answers787
viewsSyntax error problem in Else python
I’m having a problem in this Python code where, when I try to run, it informs me that there is a syntax error in a else. Follow the code and error below: n=int(raw_input('')) i=0 for i in…
python-2.7asked 7 years, 7 months ago ArturKS 1 -
0
votes1
answer268
viewsGet data from a specific column in CSV
I have a question in an exercise. I have a table where I need to get results from only one column. the data are as follows: ['2017-01-01 00:27:45', '2017-01-01 00:31:13', '208', 'Damen Ave &…
-
0
votes0
answers38
viewsHow can I call a.py program on a server within another local.py program?
I’ve been interacting with a server within a program I’m doing using the os.system() function as if I were using the console itself. os.system("ssh [email protected] 'comando a ser realizado'") For…
-
0
votes2
answers96
viewsWhat’s wrong with this print line = ('Hello,' + full_name.title() + '!')?
I’m new to programming and I’m following Eric Matthes' book exercises. In the text editor, I typed print = ('Hello,' + full_name.title() + '!') and an error message appeared.…
-
0
votes2
answers1177
viewsSaves browser status or cookies using Selenium
I’m doing tests using the web Whatsapp, so every time I run Selenium, read the qr code and start the tests, and I have to do this every time, I’d like to know if there’s a way to save the state of…
-
0
votes1
answer149
viewsSelect the two highest values of a vector and add them up?
atletas = [] while True: nome = input("Nome: ") if not nome: break saltos = [] for i in range(3): salto = float(input("Distância {}:…
-
0
votes2
answers104
viewsusing any in python
I have 2 lists with several fixed/mobile numbers. Example: Lista 1: ['0169924233316','01687665544','01978553322']<br> Lista 2:: ['0169924233316', '01788226541']<br> Within a go, I…
-
0
votes1
answer66
viewspyautogui error, values
I want to create a macro that performs some tasks. [OK] 1° Step: Remember the X and Y. COD: def recordMouse(): time.sleep(5) print "New record in 3s" x, y = pyautogui.position() c =…
-
0
votes1
answer223
viewspyhon error, pyautogui
I created a bot(macro) which has the function of making a few clicks in X time. I made the loop for this. def afkLoop(): #Loop pycontrol.broken() #Função time.sleep(1800) #Timer afkLoop() def…
-
0
votes1
answer370
viewsSyntaxerror: invalid syntax for no apparent reason
In python, I was doing a function in an attempt to make a client program: And I made this mistake, not knowing why: Can someone help me?…
python-2.7asked 6 years, 10 months ago Alexandre Gonçalves 1 -
0
votes1
answer87
viewsPython function equivalent to Crypt in PHP
I have a program in PHP that encrypts a password with the method crypt: $crypt = '$1$/E0xe3/3$yPzJElk.aVSd5JoQTopDZ/'; if($crypt == crypt($_POST['key'],$crypt)) And with that I get the following…
-
0
votes1
answer30
viewsFile corrupts while trying to copy it
I was trying to copy a file using Python, but the file corrupts... Look at the code: #!/usr/bin/env python cf = raw_input("File: ") ds = raw_input("Destino: ") with open(cf,"rb") as fl: for l in…
-
0
votes1
answer39
viewsNameerror when entering the value read by the input function
I’m running version 2.7 of Python: Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 When I try to spin that code line: x = input('Enter your name:') print('Hello, ' + x)…
-
0
votes1
answer1038
viewsProblem with python/ Decode
I have 2 functions, the first prepares html and writes to a file . txt so that the second function opens this file and generates an email through outlook. In the body of the message, will be placed…
-
0
votes1
answer25
viewsOrganize tabs in pyqt4
Good afternoon, you guys! What command do I use to "break" the line of tabs? I would like 3 tabs to appear on a line and 3 tabs just below it. The skeleton I have regarding tabs is: # layout tab…
-
0
votes1
answer107
viewsInstallation geopy python 2.7
I have python 2.7.12 installed on my computer (Ubuntu 16.04) and installed geopy (1.11). However when I try to run my script, this error appears: from geopy.distance import lonlat, distance…
python-2.7asked 6 years, 8 months ago Luana 59 -
0
votes0
answers70
viewsHow to turn a Qlineedit string into a float?
Good night, you guys! I’ve been trying to turn the string of a Qline Edit into a float and I can’t!! Always returns the error saying I can’t convert string into float. What can I do to get around…
-
0
votes1
answer84
viewsDoubt Python libraries
Good afternoon! I am new to development using the Python language, I would like some good library tips to be studying and mainly one aimed at "manipulating websites" (currently I only know the…
-
0
votes1
answer379
viewsHow to compile multiple python files into one using Pyinstaller?
I am making a calculation program that is divided into 3 files py: graphical interface file (cerberus.py) file making the calculations(calc.py) file responsible for data plotting(plot.py) I tried to…
-
0
votes1
answer166
viewsTreat functions that return multiple Python values
For example, I have a function mergeSort(alist)that has return return count, blist i.e., returns an integer that is the inversion counter and a list of values. When passing a list 5 4 3 1 2 5 and…
-
0
votes1
answer320
viewsSum indices of a vector respecting condition
I have the following code: import random usuarios = 2 APs = 2 distancias = random.sample(range(0, 100), usuarios*APs) teste = [sum(distancias[x: x + usuarios]) for x in range(0, len(distancias),…
python-2.7asked 7 years, 4 months ago Danilo 447 -
0
votes1
answer540
viewsHow to assign the elements of a list to different variables in Python?
I have a list, like the following: lista = [1, 2, 3, 4, 5] Even without knowing how many elements there are inside the list, how do I assign each element of the list to a distinct variable? (as in…
-
0
votes1
answer150
viewsSimulate area of action of points in matplotlib
I need to create a graph where, given the coordinates of the points, an x-ray circle is created around these points. Simulating the area of action. I have the following script:…
-
0
votes1
answer624
viewsExercise in the ordering of tuples
I’m getting beat up in a Python exercise. He asks for the following: Create a function that: Receive a list of tuples (data), an integer (key, zero by default equal) and a boolean (reverse, false by…
-
0
votes0
answers84
viewsProblems using the requests library
I am having trouble using python2’s requests library. I have already performed the installation and when I run pip install requests I see she’s already settled in. Someone could help? Python 2.7.14…
-
0
votes0
answers34
viewsConstant error in the use of strptime
Expensive, I always worked with strptime without major problems, but a mistake started to appear that I did not find in any quote: from datetime import datetime a = "20160228" date =…
-
0
votes1
answer240
viewsMoving files in folders
I have a folder called test. Inside this folder there are 1000 subfolders from 1 to 1000. Within each of these subfolders there is another folder called Reports Inside each folder Reports there is a…
-
0
votes2
answers362
viewsIs adding more than one element to Append possible?
I can add more than one element to the function append? For example: convite.append("Carlos", "Junior") convite["Alberto", "Eduardo"]
-
0
votes3
answers693
viewsI can’t make the sum of the first 100 prime numbers, where am I wrong?
#python3.7 cont = 0 cont_100 = 0 primos = 0 num = 1 soma = 0 while True: primos += 1 while primos != num: if primos % num == 0: num += 1 cont += 1 if cont == 2: soma += primos num = 1 cont_100 += 1…
-
0
votes1
answer66
viewsPython - Creating a program that changes itself
I would like to create a program that is able to change itself, that is, I run the script, and it changes the script itself, creating a kind of bookmark. The big problem is that I can’t change the…
-
0
votes0
answers75
viewsHow do I convert the image data to float? Or is there something wrong with the code?
I’m testing a code and I had problems: I can’t see the image. The message that appears is: Typeerror: Image data cannot be converted to float (picture data cannot be converted to float) CODE: from…
-
0
votes2
answers326
viewsI need to make a Python entry by storing it as a list, all in one line
I am doubtful in a college exercise, I need to store 3 data which are: Vehicle number, mileage and consumption in each variable of type list, but due to be different types, with the first 2 being…
-
0
votes1
answer410
viewsSort TXT lines in numerical order
I need to invert all the columns of my txt file, using python. txt file (example): Regra n10 - exemplo Regra n9 - exemplo Regra n8 - exemplo Regra n7 - exemplo Regra n6 - exemplo Regra n5 - exemplo…
-
0
votes1
answer198
viewsMaintaining the relationship between vector elements after a Python sorting
I have two vectors X and Y, I want to plot an XY graph with them, that is, the element at position X[0] corresponds to element Y[0] and element X[1] to Y[1] and so on. But my vector X is disordered,…
-
0
votes1
answer40
viewsHow not to kill a subprocess opened by another python file?
I would like from a script in python to run a program I developed in python as well. However I would like to terminate my script but not the program I opened by it. I’m opening my program for a…
-
0
votes0
answers35
viewsFunction being called before being called by GUI
I have a software that I am using Tkinter as GUI, to receive some parameters that the user will pass me. In this software I have 1 problem and a doubt. the problem is this, just when I run the…
-
0
votes1
answer2830
viewsConverting Bases to Python
The code below takes a decimal number and converts to bases from 2 to 9 def converte(numDecimal, base): if numDecimal != 0: numConvertido = "" while numDecimal > 0: resto = numDecimal % base…
-
0
votes0
answers110
viewsHow to save and finish python code?
I’m using a camera to capture video, and save the video. I’m trying to save and finish the code with a command in the IDLE(python) but I’m not getting it. Actualement to finish and save the program…
-
0
votes2
answers171
viewsCoding problems
I’m having codage problem that I can’t solve. I’ve tried several suggested things but none works: Script: # -*- coding: utf-8 -*- import sys line = ["Oi tudo bem com você","eu GOSTO de café", "esta…
-
0
votes1
answer906
viewsHow to perform calculations on top of a CSV file with Python 2.7?
I am learning some commands for analyzing data extracted from a CSV file and locked in the following situation: I want to use as a basis this CSV to realize the average of the room: Nome;P1;P2;P3…
-
0
votes1
answer54
viewsFunction to increment the file name - python(opencv)
i have this code that saves me a video every time I run the program with the name video0. out = cv2.VideoWriter(video0.avi', fourcc, fps, (int(width), int(height))) I wanted him now every time I ran…
-
0
votes1
answer2644
viewsDate calculation with Python
I have a script that needs to make a difference between 2 collected dates of some files In this case the script collects the date of a file. txt (dt_log) and the current Systema date (dt_sys) and my…