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
votes2
answers3540
viewsFactor factor in python,
Guys, I’m new to programming, and doing exercises I came across the following question: Make a program that calculates the factorial of an integer number provided by the user. Ex.: 5!=5.4.3.2.1=120…
-
0
votes1
answer1154
viewsGame Snake in pygame: Snake growth function
I’m writing Snake in pygame, but I don’t have a very clear idea how to implement snake growth functionality. I made a list ("lista_cobra") containing the coordinates of the head (which has…
-
0
votes1
answer36
viewsError while doing Reverse:
in Eat.txt there is the following content: 02:26:31 14:44:45 09:53:27 14:17:35 12:33:44 09:30:12 I’m reversing the order of the elements ad following way: import sys with open 'eat.txt as f: lines =…
pythonasked 7 years, 12 months ago Guilherme Lima 3,129 -
0
votes1
answer111
views -
0
votes1
answer54
viewsWhat if I don’t want any queryset in a Django view?
There are urls that I only need to set a Session or query a restful....enfim. API What if I don’t want a queryset? Because Django seems to force me to define a? Would have some kind of different…
-
0
votes3
answers1358
viewsHow to create a variable through the answer typed by the user in Python?
For example, we can use this code to assign the value to a variable: idade = input('Digite sua idade: ') What I’d like to know is, if instead of assigning a value a variable is possible to create a…
-
0
votes0
answers209
viewsIs there a way to connect to a socket server hosted as localhost by CMD?
I wonder if there is any way to run my server in python socket and connect to it using command prompt. Is there any way to do it?
-
0
votes1
answer5357
viewsMultiplication of matrices in Python
Hello, I’m making a python algorithm that makes the product between two matrices, but I’m having trouble displaying the resulting matrix matriz = [] linha = [] linha2= [] matriz_result = [] result =…
-
0
votes0
answers40
viewsWhat is a tuple for and how does it work in python?
What is the ultimate goal of using a tuple? I already know the difference between a tuple and a list. I want to understand how the tuple works and what is its true purpose at the level of use.…
pythonasked 7 years, 10 months ago Luís Almeida 806 -
0
votes1
answer120
viewsProblem creating environment with Django
I’m trying to create a project in virtualwrapper environment with virtualwrapper tool, in this environment I installed Jango but when trying to create a project with the command django-admin…
-
0
votes2
answers1323
viewsPIP does not work in virtualenv
After activating the virtutalenv Pip does not work, I get the following error wilker@debian:~/Documentos/Git/Curso Django/Blog$ source bin/activate (Blog) wilker@debian:~/Documentos/Git/Curso…
-
0
votes1
answer3153
viewsPython error api-ms-win-crt-Runtime-L1-1-0.dll
Using Windows 7 64bits, I downloaded and installed python 3.5 but when starting the program I get the following error message: The program cannot be started because it is missing…
-
0
votes1
answer779
viewsError sending simple email with python
I am learning to send emails with python. Early on, I came across an import error of the methods of the smtplib module, which generated this question: Import error when sending simple email with…
-
0
votes2
answers338
viewsHow to get all ips associated with a Python domain?
I need to create an application that gets all the ips associated with a domain. I tried using the following Python code: import socket print(socket.gethostbyname('facebook.com.br')) However, just…
-
0
votes1
answer645
viewsPython Error: 'int' Object has no attribute '__getitem__'
I’m writing a genetic algorithm in Python to find the minimum of some mathematical functions. The problem is that when I go to calculate the fitness of a function and store the result in the fitness…
-
0
votes1
answer703
viewsWith doing Facebook posts with Python?
import facebook token = 'meu token' graph = facebook.GraphAPI(token) graph.put_object("me", "feed", message="Hello, World!") Friends, I’m using Ubuntu and Python 2.7 and 3.5.2 The following error…
-
0
votes1
answer777
viewsInstall Mysql to use with Python
I’m first in python and I want to know how to install mysql to store terminal information. I use wamp/mysql to develop in php, is it possible to make some relationship between them? (use wamp mysql…
-
0
votes1
answer126
viewsInstall Curl Python library 3.4.4
Someone has a . zip link to install the "import pycurl" Use Windows and Python 3.4.4
-
0
votes1
answer1198
viewsImport of numpy package
In Windows 10, using Python 3.6.0. How do I import the numpy1.11.2 module? I already used miniconda and the package was loaded but I do not get success in the interactive python Python 3.6.0.…
-
0
votes1
answer322
viewsHow to filter PCAP file with Python?
The PCAP file was generated on 12/21/2016 and is 5 GB so it is impractical to try to open it with wireshark (graphical user interface) I installed tshark on Ubuntu and while reading the manual, I…
-
0
votes0
answers122
viewsPython web application with Django - Bootstrap and Crispy only work if you have internet connection
My application uses these two frameworks Boostratp and Crispy, when I am connected on the internet, everything works perfectly, but when disconnecting the internet the site loses all style. Making a…
-
0
votes1
answer86
viewsGame of life, what’s wrong?
I’m training Python and recently I’ve been trying to recreate the famous "Game Of Life", I managed to avoid code flaws but it is still not behaving properly. The program was to behave this way:…
-
0
votes1
answer94
viewsa bug in the range() function?
I’ve been writing a function for a class that takes a dictionary and converts it into a string to represent a matrix. def __str__(self): grid_str = ['' for _ in range(self.heigth)] for y in…
-
0
votes1
answer503
viewsImport attributes from models classes from another app
Good afternoon guys, I’m good a doubt! I am using 2 Apps in Django admin App1 = Registrations App2 = Controlling Fellows I imported into "Stock Changers" (App2) the app1 model, the "Person" class in…
-
0
votes1
answer1416
viewsCalculate a Python string
I would like to make a calculation of a string that I receive, for example: var = '1+2' Wanted to turn this string into an account, to return 3 to the variable var and not '1+2', but this would not…
-
0
votes2
answers3130
viewsPython - Module: Tkinter - window manipulation
as every good new programmer, at the beginning comes up many ideas and, one of them was the following: how do I manipulate windows? how so? remove the rounded corners when running on Windows 7.…
-
0
votes1
answer49
viewsHow to escape HTML from an entry in Pyqt?
Both Pyqt4 and Pyqt5 can interpret HTML entities. I have a place where the text is displayed in HTML format. However at the time of sending a text made by a certain QLineEdit, I need this text to be…
-
0
votes2
answers152
viewsIs it possible to compare two variables coming from a view in Django?
Well, I want to compare two variables coming from a view on Django. I’m doing one for and iterating and comparing a Charfield value (student.matricula) with another Charfield (frequencia.matricula)!…
-
0
votes1
answer612
viewsPyqt calling file created by Qtdesigner
I developed a Pyqt window with Dialog with Buttons Right template but calling me in my main class gives me an attribute error. I saw in the YT video that the guy used Main Window as a template and…
-
0
votes0
answers282
viewsCreate super user inside a Docker container that this used with Compose
I have a Jango project that is running with Docker-Compose, what I need to do and very simple, run python Manage.py createsuperuser, however, even setting the command via dockerfile or in . Compose…
-
0
votes1
answer79
viewsc1803 error in kyvi installation
Every time I try to install kyvi the following error message appears "fatal error C1083: Cannot open include file: 'GL/Glew. h'
-
0
votes1
answer45
viewsWhat is the difference between sublime_plugin.Textcommand and sublime_plugin.Windowcomand?
When we create a plugin, Sublime Text usually creates a sample using the class sublime_plugin.TextCommand. import sublime import sublime_plugin class ExampleCommand(sublime_plugin.TextCommand): def…
-
0
votes1
answer267
viewsPython conditional deviation
I made this code, but it does not compile. I am using Visual Studio 2015. # Exercicio Python 2.6 import utf8 #PROGRAMA TESTE DOS IFS #Usando Coding para assento nas Strings input ("Digite valor de A…
pythonasked 7 years, 7 months ago Rafael Von Rammstein 11 -
0
votes2
answers136
viewsError whenever using max python function 3.6.1
am starting me in python and in this code I send below whenever the syntax error execution invalidates. Can you give me a help? lst=[6,10, 2, 1, 9, 35] lstord= sorted(lst) lstord.reverse() print max…
-
0
votes1
answer2731
viewsAccent error while saving Python file
I’m not being able to save a file with an accent in python, I’ve come to ask for your help; import csv f = open('output.txt', 'w') data = [] def parse(filename): with open(filename, 'r') as csvfile:…
-
0
votes0
answers667
viewsOperationalerror: no such table: can anyone help me?
I am trying to read a sqlite file in Jupyter Notebook, however this error appears : Operationalerror: no such table: someone can help me? import sqlite3 conn = sqlite3.connect('escola.sqlite') c =…
pythonasked 7 years, 9 months ago Paula Santos 13 -
0
votes2
answers941
viewsHow to turn a String list into a Float list?
If I run this code, it will give a string list: So that I can not make the average number correctly (since it is in string). What can I do to have the number printed in float/int? Does this "bug"…
-
0
votes1
answer300
viewsPrint dictionary using matplotlib
Hello, I have a dictionary of the type: and I would like to print a line chart with the key k as x and v as y. tried a lot of things but keep getting errors: plt.plot(lr.keys(),lr.values())…
-
0
votes1
answer169
views2 types of products in the same view
How could I list 2 types of products on index (Pizzas and Drinks) Defining a order by and dividing into divs different (div of drinks, div of the pizzas), follows what I have: class…
-
0
votes0
answers58
viewsHow to Get the title and cover photo from a Google Photos shared album
How do I get the title and cover photo of a Google Photos shared album from the share link? If you post a link to a Google Photos shared album on Facebook, you’ll see that Facebook features the…
-
0
votes1
answer430
viewsHow do I integrate my Django project with Scrapy?
I’m looking to develop a simple project using Django where I will create a web page and this page will capture data from other pages. The problem is that I cannot integrate the Scrapy with Django.…
-
0
votes1
answer1662
viewsHow to print all vowels present in string?
I’m learning to program now, and I’ve chosen Python, and I’m having trouble solving this school exercise. The code that I have is: nome = input("Digite o nome: ") b = nome.find("a") This code finds…
pythonasked 7 years, 7 months ago Edson Fonseca 67 -
0
votes3
answers331
viewsAvoiding code duplication without the use of switch/case in the Python language
Friends, I have the following code in Python: data_hoje = time.strftime("%d %b %Y", time.gmtime() ) #data de hoje data_desejada = time.strftime("%d %b %Y", time.gmtime(time.time() + (3600 * 24 *…
-
0
votes1
answer4423
viewsCSV file reading and data storage in a vector
I have the following difficulty: I need to read the data that is inside a CSV file and store it in an array to perform calculations with such data, but I don’t know how to do it. I’m using Python…
-
0
votes2
answers4543
viewsTurn columns into python pandas rows
I need to make some modifications to a dataframe but I’m not getting it. I’m using pandas. I have the table below: But I want her to stay that way? Someone can help me?…
-
0
votes0
answers102
viewsWhat is the purpose of WITH?
I’m studying a little Python around here, and I always come across the command with. I searched the documentation and other sites, read articles in English and I also gave an answer about this…
-
0
votes2
answers16445
viewsHow do I delete a file from a python folder
the code below lists the files of a particular directory, wanted to know how I do to delete only 1 file from this directory def etc(): path ="diretorio"` dir = os.listdir(path) for file in dirs:…
-
0
votes0
answers377
viewsPython, Selenium and Phantomjs
I’m using Selenium with Python and Phantomjs. I want to click a button from the youtube page, but it always gives an error. Someone can help me?…
-
0
votes1
answer187
viewsWriting IP addresses to file, each IP on a different line using Python
from scapy.all import * pkts = rdpcap("lalalao.pcap") for p in pkts: ## print p.time if IP in p: #if packet has IP layer src_ip = p[IP].src dest_ip = p[IP].dst print src_ip f = open('IP_src.txt',…
-
0
votes1
answer1190
viewsGenerate list/matrix by bringing all combinations of n elements taken p to p in python 3
Example: A B C D 4 elements result: WITH TWO ELEMENTS AB AC AD BC BD CD WITH THREE ELEMENTS ABC ABD RCA BCD