Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
0
votes1
answer676
viewsObtaining numerical values of mathematical graphs with python
Assuming you have a data file that allows you to plot a 2d graph (straight, parabola, conical), is it possible, starting from the image of the graph, to extract the numerical values that generated…
-
0
votes1
answer709
viewsDjango-admin.py execution error on Django 1.9
I am trying to learn Jango and would like to understand this notification I get every time I run the Django-admin command! Note that only Django core Commands are Listed as Settings are not properly…
-
0
votes1
answer1500
viewsUnused import statement - Pycharm
When trying to import using Pycharm: from selenium.webdriver.common.alert import Alert it leaves the text in gray, and shows unused import statemnet. tried to use the: # noinspection…
-
0
votes0
answers256
viewsError migrate : Typeerror: Required argument 'year' (pos 1) not found
I’m having trouble executing python manage.py migrate, until I create the tables more at the end returns me the following error : Typeerror: Required argument 'year' (pos 1) not found someone could…
-
0
votes1
answer2321
viewsFetchall() limited in python
I’m making a code that makes a query in postgres and returns in a list, but this is giving memory error. The part of the code that does this: c = conn.cursor() c.execute("SELECT latitude, longitude,…
-
0
votes1
answer1153
viewsWhat is the difference between IDLE Python 3.5 Shell and Python 3.5 (CMD)?
I installed Python for Windows on my machine but had one question: Both IDLE Python 3.5 (Shell) and Python 3.5 (CMD) have been installed. Is there a difference between them? Do any of them have more…
-
0
votes2
answers226
viewsWhy does the following code print 'None' instead of the list?
The program must receive values, in a quantity specified by the user. I need a list to be created with these values. Why does this code not work? quantidade = int(raw_input()) inicio = 0 lista1 =…
-
0
votes2
answers1819
viewsHow to calculate the percentage of items performed in a data tree in the list format?
There is the following list: [ [0, False], [1, True], [1, False], [2, False], [2, True], [2, False], [3, False], [3, True], [2, False], [1, False], [2, False] ] This list forms the following tree:…
-
0
votes2
answers121
viewsTurn cycle into higher order function
Good afternoon, I have this function containing a cycle: def ciclo(x,y): lista = [] for i in x: if i[0]==y: lista.append(i[3]) return sorted(lista) And I wanted to turn it into a line of code, using…
-
0
votes1
answer1609
viewsIterate in multiple text files
Good afternoon. I have the following goal: I have a series of text files and I want to create a script to iterate over all of them and count how many times certain strings appear in them. I was able…
-
0
votes2
answers677
viewsDictionary for list of dictionaries
I have a dictionary like the following: {'Eva': [4], 'Ana': [53], 'Ada': [12]} And I intend to turn it into a list of dictionaries for this guy : [{'Nome do Dono': 'Eva', 'Media de idades' :…
pythonasked 8 years, 7 months ago Força Chape 349 -
0
votes3
answers115
viewsMultidimensional array
I am trying to create a multidimensional array. I first intended to place all the first elements with value 2 so I did: l=4 x=6 TSup=[ [ 2 for i in range(l) ] for j in range(x) ] print TSup and I…
-
0
votes1
answer124
viewsProblem to install RPM on Ubuntu
I’m trying to install some packages RPM in my Ubuntu, but I am getting dependency failure messages. The strange thing is that all dependencies are already installed in my ONLY. I created a directory…
-
0
votes1
answer419
viewsRounding up
I have the following list of dictionaries and the values correspond to the average value , for example, in the first appears 4 , but in fact of the 4.6666. I’d like to know how and what it does , I…
-
0
votes0
answers51
viewsError server 500 Reverse openshif with Django
I deployed an application in openshift and basically the same is a crud, what happens, whenever I try to register a new client the server returns me "server error 500", does anyone know tell me why…
-
0
votes0
answers875
viewsChat using different networks
I’ve been chatting on python , and when I test locally, the chat works, but when I test on networks that are in different places, it doesn’t work, example server on my computer and client on a…
-
0
votes1
answer149
viewsRest API Django does not work
I have a problem in Python/Django. The tables school and school_application_info are related. However, there is no record of any school_id in school_application_info. So I added null=True,…
-
0
votes1
answer131
viewsInitial input of a list after using set
I used this code initially to aggregate in dictionaries the values of B which had equal value in A: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] B = [0.2, 0.3, 1.1, 0.2, 0.2, 0.7,…
-
0
votes1
answer818
viewsI need to know the size of a file even before it is created
I’m on a college job and it’s hard to solve... it’s like those wordlists that hackers use, but it’s for didactic study. QT: Generates a file with all possible groupings using the concept of simple…
-
0
votes1
answer224
viewsproblem with existing condition in while python. Turtle
I’m having a hard time solving an exercise in a programming book. The exercise asks me to create two turtles and move them randomly, so that each turtle walks 50 units forward, then turn either…
-
0
votes1
answer94
viewsHow can I use this code?
import socket, sys, os print "][ Attacking " + sys.argv[1] + " ... ][" print "injecting " + sys.argv[2]; def attack(): #pid = os.fork() s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)…
-
0
votes2
answers247
viewsImage upload using CGI Python - Doesn’t work!
Hello, I created an html file with one and I intend to select an image from a directory and after clicking on Ubmit this image should be saved in another directory. Some help? That’s what I’ve tried…
-
0
votes1
answer974
viewsWhat is the [Httpget] statement for?
In a certain method of mine Controller raised in the Asp Net MVC, I learned that I could put the statement [HttpGet]. In other cases, as in my models, I realized that can be put too [Length(10)] and…
-
0
votes1
answer179
viewsSet the behavior of the Python window when the mouse is over and outside it
I am using Pygtk in Python 2.7 and would like to set win.set_decorated(False) when the mouse is outside the window and win.set_decorated(True) when the mouse is over the window. How to do?…
-
0
votes1
answer1004
viewsREGEX - extract some text in a string
i have the following string ==> "The guy from Pamonha crashed his car into the guy’s car" I am wanting to extract starting from ("the guy ...") and ending in ("... the car")$ someone could help…
-
0
votes1
answer533
viewsHow to print page
I want to create a template for printing data but I’m a little lost on how to do this, I have a print name button, the same is found in a table that contains the customer name, telephone address etc…
-
0
votes1
answer74
viewsThrough a panel of 2 lists make a chart
I have 1 table with 2 lists as for example the following ones , where the first one contains dates in the YYYYMMDD format and the second one contains the number of times a crime happened that day.…
-
0
votes1
answer1174
views"Syntaxerror: invalid syntax" error
I was trying to run a very simple program through the terminal (use gnome Ubuntu): #encoding: utf-8 y = int(input("Ultimo número: ")) x=0 while x <= y if x % 2 == 0 print (x) x=x+1 and I came…
-
0
votes2
answers560
viewsList indexes in python
Good afternoon! I have the list: a=[4,3, 1, 2, 3] and the list: sub_ind_novo=[96, 7, 97, 23, 18] And I needed to link the lists by getting the result: no97. G1 #when sub_ind_novo is 97, the…
-
0
votes1
answer102
viewsPython 3 dicts and zip problem
I’m having trouble with my job dict(zip(x, y)) when I pass as parameter the two lists (x and y) the zip does not create the list of the original size, randomly creates the list in the original size,…
-
0
votes1
answer1247
viewsSolve duplicate items in Dict in Python 3
I’m having trouble with my dict. I need it not to delete duplicate key values. I have a style tuple lista_tupla = [(1, [1, 2, 3, 4]), (2, [5, 6, 7]), (3, [7, 8, 9]), (3, [10, 11, 12]), (4, [13, 14,…
-
0
votes1
answer56
viewswhat is the error of this code
class Point3D(object): def _init_(self,x,y,z): a=str(x) self.x=a a=str self.y=a a=a+"," a=str(z) self.z=a def _repr_(self): return "(%d,%d,%d)"%(self.x,self.y,self.z) my_point=Point3D(1,2,3)…
pythonasked 8 years, 4 months ago Emanuel Holanda Barroso 11 -
0
votes1
answer76
viewsappend string and looping 'for'
def conf_dir_exist(lines): temp = '' print(lines) #isso é uma tuple. for line_a in lines: for line_b in line_a: if(os.path.exists(line_b) != False): pass else: temp += ''.join(line_b + '; ')…
-
0
votes1
answer132
viewsPython. Picking up a substring in a formatted text
Hello. I have a string formatted with several attributes, I need to get all the "text" fields. In this example, I need to take "Gmail" and "Youtube" and discard everything else. Using Python…
-
0
votes2
answers117
viewslist.remove() in a row
have the list: lista = ['', 'a', 'b', 'c', ' ', '', '', ' '] and from her I’m trying to remove the blank items: [''] or [' '] then I have the following code: if(ret_b == [' ']): ret_b.clear() my…
-
0
votes2
answers2753
viewsCapturing user keystrokes in Python on Linux
import pyHook import pythoncom def tecla_pressionada(evento): # print("Alguma tecla pressionada") print (chr(evento.Ascii)) hook = pyHook.HookManager() hook.KeyDown = tecla_pressionada #sem ()…
-
0
votes1
answer483
viewsHow to do a class or test function with pytest?
Be a Python program, for example, the calculation of Fibonnaci: def fibR(n): if n==1 or n==2: return 1 return fib(n-1)+fib(n-2) print (fibR(5)) How to do a test class/function using pytest, for…
-
0
votes1
answer224
viewsHow to get the headlines of the Olympics on the CNN website with Python using Beautifulsoup?
I’d like an example of how to take the headlines of the Olympics in http://edition.cnn.com/sport/olympics using Beautifulsoup.…
-
0
votes1
answer131
viewsError executing GUI application in Python 3
Error executing GUI application in Python 3. File "/home/nexide/PycharmProjects/untitled1/.idea/testew.py", line 1, in <module> from tkinter import * ImportError: No module named tkinter…
-
0
votes2
answers3050
viewsScroll through a Dict until it is empty in Python
How do I go through while a list of values and keys is non-zero, just add the values (values()) in a list? The code I have is this: hey = ['item1', 'item2', 'item3', 'item4'] print("hey", hey) lol =…
-
0
votes1
answer105
viewsProblem in Dict class and merging large amount of elements per Python Dict
Hi, I’m having trouble with dict. I have two lists: lista1 and lista2, both the same size. When I execute the command: dicionario = dict(zip(lista1, lista2)) produces a dictionary "smaller" than the…
-
0
votes1
answer177
viewsImplementing a TCP traceroute
I’m trying to understand the code below (found on the Internet): #!/usr/bin/python3 from scapy.all import * target = input("Informe um alvo: ") destport = input("Porta de destino: ") port =…
-
0
votes1
answer1178
views -
0
votes1
answer419
viewsPython - API 2.0 Zenvia - urllib.error.Httperror: HTTP Error 400: Bad Request
The software below has the following intention: extract data from an excel file. XLS and send SMS with information extracted through the Zenvia platform. Here follows the API 2.0 link of the Zenvia…
-
0
votes1
answer1363
viewsPush 'infinitely' keyboard button
I am running a python3.5 test using the pyautogui library. My goal is for the algorithm to press buttons for me. import pyautogui while True: pyautogui.press('f1') In this case, it is pressing F1. I…
-
0
votes1
answer4056
viewspython progress bar 3
I’m trying to assemble a progress bar to tell the percentage of my Python script execution with varying different functions, however unsuccessfully how I would create such progress bar?
-
0
votes2
answers205
viewsRestrict __setattr__ when the attribute does not exist within the Python instance
Hello, I need to know how to assemble a class that cannot have attributes implemented after the instance. Ex: class Foo(object) def __init__(self, a='hello', b='world') self.a = a self.b = b…
-
0
votes1
answer65
viewsSelect specific day in an np.array containing datetime
I have a np.array.astype('Datetime[s]') called T with several days at random times. I need to select a few days for separation. I tried to: for i in np.arange(MinTime,MaxTime,np.timedelta64(1,…
-
0
votes1
answer118
viewsCreating an ARPING
#!/usr/bin/python3 #Fazer arping de conexao import sys from datetime import datetime from scapy.all import * try: interface = input ("\n[*] Set interface: ") ips = input("[*] Set IP RANGE or…
-
0
votes2
answers699
viewsRegex Python Searching dates
resultado_limpo = ((busca.find_all(string=re.compile(r'\d{2}\/\d{2}\/\d{4}\n\t\t\t\t\t\t\t\t')))) I am trying to find dates in dd/mm/yyyy format need search with year only 2016 and have how I put…