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
votes2
answers258
viewsif statement - use of parentheses
Using parentheses with if, alters code performance or modifies something? Example, this: if (1 != 2): print('É True') compared to: if 1 != 2: print('É True') If it is only aesthetic, which form is…
-
1
votes1
answer466
viewsFunction to create Column
Hello, I’m trying to create a column using a function, but it’s giving an error, which should be silly to fix, and even so I couldn’t, come on: import pandas as pd import numpy as np import…
pythonasked 6 years, 3 months ago Iuri Moura 61 -
1
votes1
answer72
viewsHow to use Pyopengl in pycharm
I did the correct installation of Pyopengl and Acellerate. I can easily use the libraries in python 3.7.2 IDLE, however when I try to import them using the Pycharm IDE I cannot use the libraries.…
-
1
votes1
answer48
viewsSave log to application folder
Hello, I made an application and added log (logging), but it is saving in the root folder '/', and I want you to save in the root folder of the application Monitor/, how do I.…
pythonasked 5 years, 8 months ago Lorena Jesus 15 -
1
votes1
answer286
viewsDeploy flask application on Heroku with flask-sqlalchemy
I have a small application written in flask and I am having problems with the database when trying to deploy in Heroku and after searching for two days I did not find any solution that suits me. In…
-
1
votes3
answers497
viewsConvert string into a list where each element in the list is 3 characters from my initial string
I wonder how I can turn one string on a list where each element of that list is a string with 3 characters from string original. Therefore if the string original was like this "AAGGGTTGG" I get a…
-
1
votes1
answer2738
viewsHow to remove unwanted characters from a list of strings?
I’m new to python and I couldn’t find an answer to my question. I get a list of texts from the database and turn it into a list of strings as below: textosPuros = df['texto'] # print(textosPuros)…
-
1
votes0
answers336
viewsSend file via network with Python
Server #!/usr/bin/env python #-*-coding:utf-8;-*- import socket import os host = "127.0.0.1" port = 8080 addr = (host, port) skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM) skt.bind(addr)…
-
1
votes1
answer110
viewsproblem in converting normal matrix to numpy
The program organizes is made to organize the lines, based on the value of the third column, I did the program and it worked, but when I use numpy matrix, gives the error below. i need to use numpy…
-
1
votes2
answers96
viewsGuidelines for using object or procedural guidance in Python and PHP
I am studying PHP and Python and I am feeling a huge difficulty, not in relation to concepts, after all they are independent of language, what is making hard the study is how PHP implements the…
-
1
votes4
answers1706
viewsFunctions of PYAUTOGUI not working
I am automating the installation of software using python with pyautogui: import pyautogui import time import pyperclip for window in pyautogui.getWindows(): pyautogui.getWindow(window).minimize()…
-
1
votes1
answer638
viewsDifference between task and shared_task in Celery?
I am implementing a time-consuming process in my Django application that needs to be run asynchronously to avoid timeout in the browser. For this, I chose to use the Celery to perform the…
-
1
votes1
answer329
viewsHow do I make a button draw something new on a screen with Tkinter?
I tried to make a data simulator in Python with Tkinter that shows the data layout in the window after scrolling. For this, I defined a function that generates a random number from 1 to 6 and draws…
-
1
votes1
answer200
viewsHow to create simple list from composite list?
What is wrong here? I would like the output to be [123, 456, 789]: a = [(1, 2, 3), (4, 5, 6), (7, 8, 9)] b = [] for num in a: x = '' for num2 in num: x.join(num2) b.append(x) print(b)…
-
1
votes2
answers11645
viewsHow to create graphical interface in Python?
Guys, I know the basics of python and I was wondering if it’s possible to create a graphical interface for the programs I do on it. Something like that interface that you can do in VBA. Can I do…
-
1
votes1
answer414
viewsRun Python code by calling for a Django form
good afternoon. I’m starting to study Python and Django. By way of study I wrote a code in Python that receives a value and a date and makes the update by TJLP. This worked perfectly. As the next…
-
1
votes2
answers123
viewsHow to make an associative matrix in python 3?
I have a code that asks for a matrix 8x8, but I need in the input He asks for the values like this: matriz [A][1]: matriz [A][2]: That is, he asks for the line in letter form and the column in…
-
1
votes3
answers1465
viewsItemgetter - Sort list of dictionaries - Python
Suppose I have the following list of dictionaries: lista = [{"nome": "Maria", "idade": 15}, {"nome": "João", "idade": 26}] And I’m using the following function to sort: ordenar = sorted(lista,…
-
1
votes2
answers709
viewsCounting elements from one matrix, storing information in another
Hello, I’m a beginner in python and I’m doing an exercise that consists in reading all the numbers of a matrix and adding in another matrix the numbers existing in the previous one and how often…
-
1
votes2
answers824
viewsRead a csv file and add your data into a dictionary
I have a code where I will have a function that will pass the data from a csv file to a dictionary. The process will be to take the films with their respective notes and add to a dictionary relative…
-
1
votes1
answer917
viewsHow to store the result of an iteration in a new variable using python?
Good morning, everyone! I’m analyzing a conjunto de dados de compartilhamento de bicicletas. In that dataset there is a column called 'birthyear', indicating the year of birth of the user. I am…
-
1
votes0
answers399
viewsPlotting graphics with functions in 3D matplotlib
Good night, you guys! I need to plot an area graph where the height z varies according to any function and its interval depends on the initial point and the final point reported. I found the example…
-
1
votes3
answers2247
viewsTypeerror: Object of type 'Nonetype' has no Len()
I’m trying to apply the NMF algorithm to a csv and then extract the phrases linked to each topic import pandas from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.decomposition…
-
1
votes2
answers2874
viewsPython, Caesar Cipher, Strings
Hello, I would like to ask for some tips to improve the code, especially in the function 'geraMsgTraduzida', to make the code more beautiful if possible. def recebeModo(): """ Função que pergunta se…
-
1
votes0
answers77
viewsWord classification
I’m trying to classify the words of a Dictionarie extracted from the Tesseract when analyzing an image with standardized texts like these: Note: The "RATING" column has been added to illustrate the…
-
1
votes1
answer439
viewsFilters in TXT file
https://drive.google.com/open?id=1ud743B57XM_iZ_wvQrSYGRrMo-5nT94p I have a file txt that I have to apply a filter to bring me a field in column 2. And then save the result in csv, so it’s easier to…
-
1
votes1
answer871
viewshow to upload python files?
what method of the request or urllib.request library do I use to upload files? (Example: upload photos to the drive automatically,or to social networks automatically or even upload videos to…
-
1
votes2
answers52
viewsHow to show a list of values of a register applying filters on numeric values?
I have to show all register with numeric field filter, I have to choose which numeric field, set lower and upper limit ex.: Show all parts with price >= to 45.50 and price <= to 90.00 I have a…
-
1
votes1
answer738
viewsPython script via PHP
I’m trying to call a script done in Python via browser with PHP. This script has only one command that serves to turn off my Raspberry Pi. PHP is that way: <?php exec('sudo python…
-
1
votes1
answer331
viewsHow to get a pixel color out of the screen limit in pygame?
I know to get a color of a pixel in Pygame I use get_at. But I have a huge background image and a lot of it is outside the screen area delimited by pygame. For example, a 1000x1000 image inside a…
-
1
votes1
answer275
viewsProblems with the 'continue' or 'while' command in Python
So I was doing some exercises in python, a language in which I’m learning to program, and it seems to me that the execution flow is not following correctly. # Converte distancia def mettocent(met):…
-
1
votes1
answer932
viewsHow to perform functions simultaneously through a Socket?
I’m developing a program in Python that’s basically a Chat, just for training. I would like it to have functions like: microphone, webcam, message and screen sharing. I’ve managed to do each of…
-
1
votes1
answer6569
viewsHow to join the lines of two Dataframes with Python?
Hello! I need to join lines of two dataframes with python - pandas. For example, let’s say I have these two dataframes X | Y | Z 1 | 2 | 3 4 | 5 | 6 and A | B | C 7 | 8 | 9 0 | 0 | 0 now I need to…
-
1
votes0
answers44
viewsHow do I remove certain lines from a csv file in Python?
I have a csv file, which contains several lines. Does anyone know what I should do to save to a new document, with some specific lines? One of the columns, 'yyyy', has data from 2015 to 2019. I…
-
1
votes1
answer395
viewsHow to add Datetime.Time in Pandas by group by?
I have a dataframe with two columns of Total CPU Time and Date, in the format below: Total Cpu Time: 00:00:14 Date : 2019-02-06 I need to do a group by Date that adds the hours (without disregarding…
-
1
votes1
answer1396
viewsSort list with Python + Django
Good afternoon guys, I have a problem, register by the Django admin a video that should be sent to my template, however I need these videos to be ordered by the field position that I have in my…
-
1
votes3
answers394
viewsLeave each word in a row (Text file) - Python
Good afternoon gentlemen! I have a text file with several lines of text. I would like to manipulate it to the point of leaving one word per line. In this way I would ignore some characters such as:…
pythonasked 5 years, 7 months ago Euler Ricardo 11 -
1
votes1
answer718
viewsImplementation of a Lexical Analyzer
Hello, guys! I’m implementing a lexical parser for a grammar I created (using Gals). Grammar validation was performed using the concept of finite automata, according to the image: At the moment I…
-
1
votes1
answer563
viewsRuntime error - question
In this problem, you should read the code of a part 1, the number of pieces 1, the unit value of each part 1, the code of a part 2, the number of pieces 2 and the unit value of each piece 2. After,…
-
1
votes1
answer188
viewsComplex operations with Python (pygame.math.Vector2)
I am learning Python and I came across a complex expression that derives from pygame.Vector2: import pygame x = pygame.math.Vector2(1,2) b = x * 5 - (1, 2) print(x) print(b) Upshot: [1, 2] [4, 8] In…
-
1
votes1
answer196
viewsQpython 3 if/Elif/Else
Why doesn’t Mey Qpython Android accept a simple if/Elif/Else condition? I’m using Python 3. x = input('Select an option... ') if x == 1: print('xxxx') elif x == 2: print('yyyy') elif x == 3:…
-
1
votes0
answers155
viewsHow to interpolate elements of an array in python?
Good afternoon, you guys! I’m new to python and I’m trying to interpolate values between two columns of a rectangular matrix. Initially I created a matrix of zeros (nx=383 nz=125). Then I filled the…
-
1
votes1
answer107
viewsHow do I let a list with multiple indexes turn into a list with only one index in Python
How do I transform an element like this: lista = [testando, este, aplicativo] on a list like this: lista = [testando este aplicativo] Someone knows how to do this, and if it is possible to do this…
-
1
votes0
answers236
viewsUsing Python to Extract Equations, Figures and Other Latex File Items
I’m on a personal project that involves leaving an article written in Latex as clean as possible for sending the translation. Aiming to increase my productivity, avoid problems of information…
-
1
votes1
answer2855
viewsMake VS Code find module installed by Pip command on linux
I installed matplotlib by sudo apt-get and VS Code was able to find the library automatically, however with pyserial by Pip command, VS Code cannot find, as I should do?
-
1
votes2
answers1075
viewsConnect SQL Server database to Django
I have an SQL Server database that already exists, and I need to connect it to my project in Django. So I come here to see if anyone has already found a solution to the problem, as they still can…
-
1
votes2
answers1576
viewsUse {%for %} and {%if %} in Django template
I have 3 videos saved in the Postgres bank where I seventh a star_date and the video only appears on template when the start_date <= date.today() My problem is in template. I have 3 buttons, one…
-
1
votes3
answers2910
viewsHow to delete the first line in a python CSV file
I need to delete the first line of a csv file, which is the header and has no use. Before deleting the line the script should write with the same name the csv file (without the deleted line). I…
-
1
votes1
answer1848
viewsRecognize the color of a python image
As part of my learning in python, I decided to create a simple program that detects the color of an image (solid color). The problem is that I have no idea how to do this, there is some python…
-
1
votes1
answer488
viewsBlack screen when running a program with Kivy
I’m not understanding why when I run the following code the screen appears only black. Someone can give me a help? from kivy.app import App from kivy.uix.label import Label from kivy.uix.button…