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
answer229
viewsFriendly Urls with flask
Good afternoon, I am developing a system using the Flask python framework and would like to know how I can create system-friendly urls? I have to use some other framework or something?
-
0
votes3
answers259
viewsHow to get response from 'apt remove' via shell_exec with PHP or Python?
With the shell_exec command I can get an answer if the result of the executed command is a single text: shel_exec('dpkg -l > list-softwares-dpkg.txt'); How to have the answer (in PHP or Python,…
-
0
votes1
answer558
viewsPython: How are Flask dynamic routes implemented?
I started to study a little bit about web development with Flask. The framework treats dynamic components of the URL as follows: @app.route('/<comp_dinamico>') def page(comp_dinamico): #…
-
0
votes0
answers23
viewsError when sorting with kmn
I am trying to sort using kmn, but is giving error shown after code: Filing cabinet search_data.py from dados import carregar_acessos from sklearn.naive_bayes import MultinomialNB import os…
pythonasked 7 years ago André Nascimento 1,258 -
0
votes0
answers972
viewsDeep search - python
import csv with open('cidades.csv', 'r') as f: list2 = [tuple(line.values()) for line in csv.DictReader(f)] def dfs_helper(list2, start_city, end_city): pilha = [] visited = [] adj_cities =…
-
0
votes1
answer889
viewsPython - Access a function above outside a class
Hey there, guys! A question regarding Python. I have a structure more or less like this: class Tela(FloatLayout): def exemplo(self): print("teste") class botao(Button): ????? Explaining: It is a…
-
0
votes4
answers361
viewsComparison between random number and typed number never says it’s right, even though the numbers are equal
I’m trying to make a program in which I can type a number n and then I would like to generate a random number between 1 and 2. If that random number is the same as n, would show "You won!" and…
-
0
votes2
answers781
viewsHow to join 2 lists in a single Matrix?
Make a program that creates two vectors, using lists and, receive 6 integer numbers in each of the vectors. Finally, the program must create a 3x4 matrix from the intercalation of the two vectors.…
pythonasked 7 years ago Hítalo Fillipy 11 -
0
votes0
answers214
viewslib not found: Pyinstaller
I am trying to assemble an executable, from a python code by the Pyinstaller library. But when executing the code by: C:\...>pyinstaller --name Aplicativo Aplicativo.pyw is generated an amount of…
-
0
votes1
answer92
viewsCustom sorting in Python
I have a list foo = ["BCB", "CAB", "CBC"] and a specific alphabetical order bar = "ACB". The result with that specific order should be resultado = ["CAB", "CBC", "BCB"] How do I sort that list?…
-
0
votes1
answer1457
viewsInsert a new column in dataframe like another column only without special characters
EX: [ Reference column x New column remove special characters in a new column using dataframe pandas]
pythonasked 6 years, 9 months ago Afonso O. Lenzi 33 -
0
votes2
answers1542
viewsSum of Integer Numbers in a txt File
I have two txt files that contain only numbers (number per line), so I want to add line 1 + line 1 so successively until the last line of each file. Each file has the same line number. **In this…
-
0
votes1
answer144
viewsUsing python to run the Notepad
How to use python to open the Notepad, then write a message, and finally using python run the Ctrl+z command
pythonasked 6 years, 9 months ago Nil Júnior 3 -
0
votes1
answer708
viewsStart a virtualenv with file . bat
I got this . bat cd C:\Users\SERVIDOR-ARQUIVOS\Documents\workspace\email\.venv\Scripts activate.bat cd C:\Users\SERVIDOR-ARQUIVOS\Documents\workspace\email\src python manage.py (comando…
-
0
votes1
answer74
viewsDjango admin line conditional background color fill
I am wanting to color an entire row of a table, if the respective column of that row has some text, there are three possible situations: 1. the text itself, 2. fields with a "-", 3. fields with…
-
0
votes0
answers1103
viewsint Object is not subscriptable (python)
I’m new using Python and I don’t know why the error is: Traceback (Most recent call last): File "C: Users Gabriel Desktop Perceptron.py", line 51, in print(perceptron(max_it, errors, alpha, inputs,…
pythonasked 7 years ago Gabriel Augusto 530 -
0
votes1
answer58
viewsIs it worth doing exercises that teach not very optimized ways of doing a program?
Well, I’m learning python and sometimes I come across some relatively difficult exercises, for example, an exercise where the program had to read a value in money and say in how many notes of 1, 5,…
-
0
votes1
answer615
viewsHow to recover the return of a function that was executed within a Thread in Python3?
I need to run a function through a Thread only I’m not sure how to recover the return of this function. Below an example of how I want to do: from threading import Thread import time def…
-
0
votes1
answer692
viewsPlace data from a spreadsheet in Excel in the database
The database here of the company generates a report in Excel, I need to save this data in a database, initially sqlite3, to be able to display this data in a Django template in the future. Example…
-
0
votes3
answers1636
viewsStart numeric variable with null value in Python
Browsing the Python Brasil site, I decided to do exercise 1 of the Repetition Structure list: "Make a program that asks for a note, between zero and ten. Display a message if the value is invalid…
-
0
votes1
answer1007
viewsHow to take a specific data type from a text file
I have a text file, structured as follows 1 Name CPF Address Telephone would like to know how I do to pick up only the lines that contain integer, in case the code(identified as 1), because I am…
pythonasked 7 years ago João Paulo de Souza 23 -
0
votes0
answers427
views(Flask) Ajax JSON with Jquery-Datatable
Good tarrde. I am trying to show my data (JSON) in a Datatable via Ajax. The HTML is: <div class="x_content"> <table id="exemplo" name="exemplo" class="table table-striped…
-
0
votes2
answers195
viewsProblem when installing Seaborn
Well, I would like to install Seaborn to plot some graphics in Python, but when running: $ pip install seaborn The following error appears: Collecting seaborn Using cached seaborn-0.8.1.tar.gz…
pythonasked 7 years ago user89389 -
0
votes1
answer103
viewsEquivalent to the "console.dir()" function in Python
There is, in the Python language (v3.6), some function that serves to display attributes and methods of an object, such as the console.dir() in Javascript? I would like to get an output similar to…
-
0
votes0
answers179
viewsGet information from another program using Python
Hello, I would like to know how it is possible to get information from another program using Python. In question, I want to develop a blinds counter for Pokerstars. Note: blinds in poker is the set…
-
0
votes1
answer314
viewsRenaming file: 'str' Object has no attribute 'group'
I’m having a problem that may be quite trivial but I’m not getting it. I found in a text by regular expression a numerical sequence of type XXXX/YYYY, after that I need to rename the file . txt with…
-
0
votes1
answer108
viewsHow to select codes with different sizes in pandas?
In Python 3, with pandas, I have this dataframe with several codes in the columns "Cpf_cnpj_donor" and "Cpf_cnpj_donor" cand_doacoes = pd.read_csv("doacoes_csv.csv",sep=';',encoding = 'latin_1',…
-
0
votes1
answer451
viewsHow to sort and sequence data from a file
I developed a program that stores a list of ids, so But for the desired purpose, the data should take the sequential form, so that the first pair of ids is something like: "889926212541448192"…
-
0
votes1
answer111
viewsFind set of numbers in a list that together add up to X
I need to do a program where I have a list of numbers (1571.48 | 327.53 | 286.60 | 349.50 | 517.67 | 247.00 | 882.73 | 274.00 | 237.50 | 301.00 | 973.50 | 288.75 | 347.50 | 326.81) And I need to…
-
0
votes1
answer60
viewsHow should matplotlib. _cntr be imported using LTS version (2.2.0) of Matplotlib?
The . _cntr module is used to build Geojson files import matplotlib._cntr as cntr When trying to load it using matplotlib 2.2.0 it returns error: ImportError: No module named _cntr How should this…
-
0
votes1
answer131
viewsInitialize the graph in matplotlib and then insert elements
Hello. Is there any way I can first open a chart with matplotlib and, after opened, perform some operations? Ex: open graph and then plot a straight line, then another, so on. I know there are some…
-
0
votes0
answers498
viewsPython code to generate event in Google Calendar
I would like a help to create a code using Python to generate events in Google’s calendar, I already have the API set up and released for this action, but I can’t make my code work, I’ve done this…
-
0
votes1
answer1017
viewsHow to make the image occupy 100% of the screen. pyqt5 -python
I have an image and I need it to occupy 100%, will be the background of my program, how to proceed? from PyQt5 import QtWidgets, QtGui import sys class Hello_World(QtWidgets.QWidget): def…
-
0
votes0
answers34
viewsweb2py - show variable value with data from a.csv file in the view
I have a web2py framework project called ucsalPY with an Aplication called ucsal. The path of application is: ucsalPY/application/ucsal (/controllers, /models, /views) In the default.py controller I…
-
0
votes2
answers323
viewsproblem with uppercase in Django
I have an uppercase problem in Jango, in the following code, it works in the first form (name) and in the last form (organ), but in the intermediary forms it does not turn the letters sent in the…
-
0
votes1
answer455
viewsError: unhashable type: dict_keys, how to resolve?
I have a code that accesses a CSV file through a function. I created a second function to change the header name of the columns (change name) and not to have to call it several times by changing the…
-
0
votes1
answer1150
viewsHow to configure Portuguese in kivy?
My App has two files, *.py and *.Kv, but I’m having problems with accents in my GUI. I’ve tried to resolve in the . py with file #encoding: -*- utf-8 -*- But the problem remains, please help me.…
-
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
votes1
answer83
viewsRegular expression that returns next words
Well I’m working on a regular expression that picks up license plates, my interest would be not just picking up the license plates, but like things next to it, for example: |Placa:AVX-4300 Fiat Uno…
-
0
votes1
answer320
viewsTotal values in Django template
I’m developing a forum that on the index page I need to show the subject, how many topics has this subject and how many posts, I can even get back number of topics, but only shows the topic with the…
-
0
votes1
answer229
viewsPython: how to edit tag with bs4
I have an html code, well polluted with Style in almost all tags, plus tags <font><span> unnecessary. How can I use beautifulsoup, to remove only attrs=style in <p> and the tags…
-
0
votes1
answer190
viewspython : Wait event on keyboard, with minimized script?
I wonder if there is a way to detect events on the keyboard with my minimized script. I’ve tried several methods like msvcrt.getch(), input("") and others but they only work with the focus on the…
-
0
votes1
answer252
viewsPYTHON - Storage of values, line by line, in txt
How do I store different values, row by row, in a txt file without deleting the previous one?
-
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
answer92
viewsIs there any way to create different tables in SQLITE3 through the same python function?
I’m creating a python bot through the python-Telegram-bot library, and it works through commands. I know that through 'cursor.execute()' I can create a table via python, but the real question is: is…
-
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
answer535
viewscan only concatenate list (not "str") to list
Hello, I’m new in python and programming I’m probably having a problem that should be very conceptual.I made this code to read a numerical sequence in a txt and rename it with the sequence found.…
-
0
votes1
answer752
viewsHow to use model variables in a view in Django
I need to calculate the average of a school report where the data are filled in in Django Admin, I would like to take each value make the media and play on a table in View. Code: MODEL class…
-
0
votes1
answer60
viewsSave data to a polygonfield
good night, I am implementing a project using Django and have the following model: class ModelExample(models.Model): city = models.CharField("Cidade", max_length=100, blank=True) state =…
-
0
votes2
answers1165
viewsVariable creation via Python user response
I would like to make the user insert a response from that answer would create a "variable" or not. I do not know if creating a new variable would be the best way, follow example: a =…