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
-
1
votes1
answer168
views404 when setting an app.route in Flask
I have this simple code available on the Flask page: from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run() As the…
-
1
votes2
answers74
viewsChoosing an index from a list
I have a list: l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] I would like to choose a value between the indexes 6 and 14 of this list, but do this 5 times and store these values in another…
-
1
votes0
answers314
viewsDisplay text in python application
I’m developing an application that makes people count by video, but it is showing the count by the terminal, how do I display "Found N people" on the video screen? follows my code: print…
-
1
votes1
answer402
viewssqlite3.Operationalerror error
I’m having a problem with sqlite3 in python, can anyone help me? the mistake is this: :~$ python3 05_create_data_param.py Nome: Henry Elias Carlos Eduardo dos Santos Usuário: Henry94 Senha:…
-
1
votes0
answers281
views -
1
votes2
answers2607
viewsMysqldb - insert value of a variable in the database
i am facing problems while trying to insert the values of my variables into the database I am trying to do as follows import MySQLdb id = 4 idade = 18 nome = 'cebolinha' email = '[email protected]'…
-
1
votes1
answer170
viewsproblem when entering Unicode value into database
I am breaking my head with this since yesterday I have done everything to enter the value in utf8 but it is not working and the following I have this code as an example #!/usr/bin python # -*-…
-
1
votes0
answers153
viewsSelecting and deleting random lines from csv in python
I need to make a small script in python that meets the following requirements: Open a csv file; Delete first row and first column from reading as it contains information that will not be needed in…
-
1
votes2
answers63
viewsLooping for as a looping parameter while
Whereas the list cont would have the values: cont = ['t','f','f','t','f'] It would be possible something like this: while(for cont in cont == 'f'): pass…
-
1
votes1
answer62
viewsProblem using Qpixmap.Scaled
Recently I’m learning how to use the PyQt4, but a doubt arose in the use of the line of code to modify the scale of an image: class Ui_Form(object): def setupUi(self, Form):…
-
1
votes1
answer2870
viewsPrint a list of objects as string in Python
I am making a program in python(2,7) where I take texts from a file,and storing as objects in a list, I would like to print the list but only returns the addresses, I am learning to program in…
-
1
votes1
answer270
viewsDeveloping a BOT for polls with wordpress plugin Polldaddy
I tried to follow: https://github.com/dado3212/PollDaddyHack import requests dados ={"poll_id" : "9484127", "answer_id" :"43276282", "number_of_votes" : "1000"} url =…
-
1
votes1
answer828
viewsCreating an executable file of a python program in windows 10
I am a Backbox Linux user but I need to generate an executable for a program written in Python. I installed Windows 10 Pro on Vmware with Python 2.7 and Python 3.4. I use Pycharm and IDLE IDE. I…
-
1
votes1
answer118
viewsMany to Many Wtforms Flask Sqlalchemy
Good night! I’m implementing a system with wtforms flask, and I stopped in the following situation: I have CRUD products and a CRUD Budget, so I will have product items in the budget (n:n). In the…
-
1
votes2
answers1216
viewsinput() and raw_input()
According to the Python 2.x documentation, it is recommended to use the function raw_input instead of input. Conversely, in the Python 3.x documentation, the function raw_input doesn’t even appear.…
-
1
votes3
answers11403
viewsFind larger and smaller unique values
I’m trying to find the smallest and largest single value of a Python array, but something is still missing. def pegaExtremosUnicos(v): i = 1 for i in range(len(v)): atual = v[i] j = i - 1; while (j…
-
1
votes1
answer2883
viewsHow do you make a socket that actually connects to other computers?
I tried to make a Python 3.5.1 socket, but when I went to test it only connects with me. I tried to connect to another computer (from my friend), but it does not connect. Does anyone know how to…
-
1
votes3
answers1852
viewsReading blank blank blank blank blank files
How do I avoid reading a blank line in a file, to any operating system, using the Python language?
-
1
votes1
answer1014
viewsIs there any way to read an XLS file and manipulate it in Python?
Is there any way to read an XLS file and manipulate it in Python? Does any library allow this?
-
1
votes0
answers1044
viewsHow to Print the Board Correctly in the Game of Old
def imprimeCampo(campo): c = 0 for i in campo: if c % 3 == 0: print ("") c = 0 print (i), c += 1 print ("\n") def ganhou(simbolo, campo): if campo[0] == simbolo and campo[1] == simbolo and campo[2]…
-
1
votes1
answer45
viewsError sqlalchemy 1044
I have a Python application that connects to a Mysql database through Sqlalchemy, but it wasn’t me who developed it. When migrating the database to another server (aws.rds go Daddy), I switched to…
-
1
votes1
answer418
viewsSending a payload with scapy
from scapy.all import * ip = IP(dst = "192.168.1.1") tcp = TCP (dport = 80, flags = "S") raw = Raw(b"Olaa") pkt = ip/tcp/raw sr(pkt) ans,unans = sr(pkt) I’m learning to use Python Scapy. I couldn’t…
-
1
votes1
answer1060
viewsPython - "Error: Indexerror: list index out of range"
I cannot find the cause of the error. The program runs well, displays all rows in the table, however, this error message appears. import re import xlrd wb = xlrd.open_workbook('exemplo.xls',…
-
1
votes2
answers4804
viewsPing manipulation in Python
I’m creating a code that pings a list of ips. I managed to make him drip and give me the answer, but I can’t make the condition that I want, which is: SE ping ok: continuar os comandos SENÃO: faz…
pythonasked 8 years, 4 months ago Cristhian Miguel 207 -
1
votes1
answer2369
viewsRead excel information in matrix form with python
I’m using Python 2.7 to read values from an Excel document. When I have only one row of values with respective header I can read, doing from openpyxl import Workbook from openpyxl import…
-
1
votes1
answer867
viewsPython Compare month list to base list and show both
I have a list of months from January to December. I have another list that has the month and a value. For example: Jan = 12.00 Fev = 15.00 Ago = 10.00 I want to display the whole year and show every…
-
1
votes2
answers5127
views -
1
votes1
answer936
viewsVariable not defined Python
I’m trying to run a code and all of a sudden you’re making this mistake, for example if you write "m" Traceback (most recent call last): File "Energias", line 5, in <module> var = input("\nQue…
-
1
votes1
answer311
viewsVariable not defined in Python for-loop
I have a problem in a code that should read 4 values using raw.input().split() and then a for-loop to turn such values into float. The interpreter returns to me: "name 'val' is not defined" Follows…
-
1
votes1
answer1023
viewsHow to print an element from a list each time a given method is called?
I’m trying to make a game of mathematical expressions in python, but I need my Mandaexp method to return an expression every time it’s called. In this method I have a list called explist, where…
-
1
votes2
answers670
viewsBuilding a python Crawler web. I need help adding threads
I am trying to develop a Rawler web for studies. It is very simple and I would like to improve it. How to use threads to accelerate/improve the process? The program could make multiple links in…
-
1
votes1
answer2620
views"Nameerror: [word I typed] is not defined" when trying to read from keyboard
I was following a little tutorial. I did everything exactly as indicated in the tutorial and gave me a variable definition error whereas in the tutorial did not give. Can someone explain to me the…
-
1
votes1
answer98
viewsCreate a new function with scrapy
I’m starting to learn scrapy and created the following function: import scrapy class ModelSpider(scrapy.Spider): name = "model" start_urls = [ 'http://www.icarros.com/' ] def parse(self, response):…
-
1
votes1
answer761
viewsCreating a program to get important news on a website
from bs4 import BeautifulSoup import requests url = 'http://g1.com.br/' header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) '…
-
1
votes0
answers124
viewsApache interpreting python script as file
I’m building a website and I want it to run a python script in the html action the issue is that my browser is interpreting the script as if it were a.py file to download <!DOCTYPE html>…
-
1
votes1
answer69
viewsProblem with urls and views inside the server
I was studying python and Django, and I decided to make my wedding website in January. The project runs perfectly on my local pc, the problem is when I deploy on digital Ocean and it gives that…
-
1
votes1
answer26
viewserror using Django.setup()
I’m trying to call the job django.setup() in version Django. 1.4, I saw that it was implemented only in 1.7. Is there any function like this that I can update, the solution would only update Django?…
-
1
votes1
answer1334
viewsHow to print a function in Python?
I’m trying to make this code work but I’m not getting it. Enter the name and year of birth, and return the correct values dps, but I can’t get back the number of years... What is my mistake? print…
-
1
votes1
answer3291
viewsHow to list all files in a folder using Python?
I am building a program that needs to know the files in its work directory. So I typed the following code. def encontrar_arq(cadena, caminho): encontrado = False # lista_arq = ls(caminho) #funcao…
-
1
votes1
answer506
viewsHow to "generate" multiple TCP clients using Threads in the same script?
I wrote the code of a simple TCP client: from socket import * # Configurações de conexão do servidor # O nome do servidor pode ser o endereço de # IP ou o domínio (ola.python.net) serverHost =…
-
1
votes1
answer819
viewsHow to create an UDP port scanner in python 3?
My code is always "port is opened". My idea is: if the destination responds, the door is open. Otherwise, it may be filtered... ##################################### # Portscan UDP # # #…
-
1
votes1
answer134
viewsPorting a Python 2 code to Python 3: Scan ICMP with errors
I have the following code: import random import socket import time import ipaddress import struct from threading import Thread def checksum(source_string): sum = 0 count_to = (len(source_string) /…
-
1
votes1
answer931
viewsPython import error modules
I’m having trouble importing the modules into my project. I was creating some tests and I can’t import the main of my project to test an end point from my test file teste_ex.py. Follows the…
-
1
votes0
answers114
viewsAdd CLASS attribute in Select widget Option Django
I’m wearing a widget=forms.Select() in a forms.Form Django, however, when trying to add a CLASS attribute in Options, which is part of Select, I can’t, only in Select itself, I searched and only…
-
1
votes1
answer129
viewsError while running python
I’m testing a python code and I have the libraries it uses, but when I run, it gives this error: Importarror: DLL load failed: %1 nờo Ú um aplicativo Win32 vßlido. The version is 64 bits. Code:…
-
1
votes2
answers110
viewsSend process to server and release user
I’m having a problem in an application that uses 3G and is very slow to keep the user waiting. Does anyone know any library that I can send the information to the server and release the user? The…
-
1
votes3
answers7867
viewsInstantiate a Python class using an object as argument
I am starting to work with Python and saw that there is no way to create multiple constructors in the same class. With that I thought I’d move on to the constructor __init__ an object containing…
-
1
votes1
answer117
viewsProblems copy "dns" package in Python
I have a problem with a script where I need to use the dns package in Python. import dns.resolver And to perform a simple DNS check: my_resolver = dns.resolver.Resolver() my_resolver.nameservers =…
pythonasked 8 years, 2 months ago Clovis Silva 11 -
1
votes1
answer677
viewsHow to receive a PDF file in Django and save to a directory?
I get an html file using type="file". <form action="/docs/enviado/" method="post">{% csrf_token %} <input type="file" accept="pdf" name = "projeto"/><br /><br /> <input…
-
1
votes1
answer46
viewsDjango csv error
Well, I have a problem reading csv and entering the data. I believe it is in Foreign key. The code is: View: def csvAih(request): coluna = 1 mes = 1 ano = 2008 while (ano < 2017): with…