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
-
3
votes3
answers713
viewsPrint the largest substring of s where the letters occur in alphabetical order
Be a string with all lowercase characters. Write a program that prints the largest substring of s in which the letters occur in alphabetical order. For example: s = 'azcbobobegghakl' The program…
-
3
votes2
answers7177
viewsHow to repeat the code at the end in python?
so I’m starting programming (just by apender even ) and wanted to know how to make the code restart at the end. I know it may seem simple but I don’t do any courses, I’m learning by myself…
-
3
votes1
answer262
viewsProject Structure in Django
I installed Django in a project and would like to make the folder structure somewhat similar to Laravel. I can organize myself better this way. But I don’t know if it’s possible using such a…
-
3
votes2
answers2545
viewsORA-00907: right parenthesis not found
Hello, I’ve been working with oracle for a little while, and I’m having this problem in the query, returns me the error: ORA-00907: right parenthesis not found, follows below the same: ("""select…
-
3
votes1
answer173
viewsPandas Python, I’m having trouble figuring out which store sold the most in the last month
I have problem to know how I do to get the last month that in the case and the month 2018/02 to can strip the average of who sold the most in this month. import pandas as pd % matplotlib inline df =…
-
3
votes2
answers2238
viewsTimeout in Python input function
teste = input('Olá qual o seu nome?') How to run something if the user takes longer than a certain amount of time to respond to input? Example: Write on screen Você demorou demais.…
-
3
votes1
answer979
viewsHow to manipulate html forms in python
I needed help with the cgi forms in python. This code works normally when I don’t insert accents: # !/Programas/Python36-32/python # -*- coding: utf-8 -*- import cgi print("Content-Type: text/html;…
-
3
votes1
answer912
viewsAutocorrelation function in Python
Hello, everybody! I have a file . txt of data with two columns (in X I have the values in days of observations and in Y the Measured Flow of a sample) I intend to calculate the Period with which…
-
3
votes1
answer132
viewsCustom Line Chart - any tool
I need to create a line chart (python, R or even excel), where each line is a product category, the y axis is the sale and x is the time. If the sale is above the finish line, the line stays of one…
-
3
votes2
answers3768
viewsWhat is the equivalent of PHP explode in Python?
In PHP, if I want to split a string into several parts based on a delimiter, I use explode. How can I do the same in Python?
-
3
votes2
answers2309
viewsWhat is the isset equivalent of PHP in Python
In PHP, if I want to know if a variable has been started, I use isset. How can I do the same in Python?
-
3
votes2
answers280
viewsHow to move multiple ZIP files at once with Python
I am creating a function to manage files using python. i would like this function to do the following: take all my zip or mp3 files (or other formats) and move them all at once to a folder.…
-
3
votes1
answer271
viewsMaximum number of lines recommended
Is there any PEP or a good practice suggestion setting out the maximum recommended number of lines a module should have? In my case for example, I keep more than one class per module, obviously…
-
3
votes1
answer447
viewsImport CSV to Pandas database without converting string to tuple
I upload a CSV file with more than 3 million lines and about 770 Mb, I use pandas and need to convert a column that is in string format. Below the column 'lbBins', which when reading from CSV came…
-
3
votes1
answer2703
viewsHow to make crontab run a Python script
I’m trying to schedule a script I wrote in Python to run on crontab, But I can’t do it. The script is simple thing, it makes a telnet connection through the terminal and sends some commands. I…
-
3
votes2
answers2549
viewsHow to set Python 3 as default in linux?
When I type the command python, Ubuntu runs Python 2.7. However, in the new versions of Ubuntu, Python 3 is also installed. When I run python -V, appears "Python 2.7.12", but I would like to use the…
-
3
votes1
answer119
viewsLibrary python asyncio
Hello, I am trying to install the asyncio library for Python 2.7.13 but I am not getting success, follow the error: rafamt@rafamttz:~$ Pip install asyncio` Collecting asyncio Retrying…
-
3
votes1
answer159
viewsHow do I know which source I’m running Python from?
I would like to know how I do to know from which source I am running the Python. For example, if I installed Python 3.5 on my machine and created a Virtualenv, how could I know, through Python…
pythonasked 6 years, 4 months ago Wallace Maxters 102,340 -
3
votes1
answer821
viewsImage overlay in Tkinter
I have a problem trying to overwrite an existing image in Python 3. from tkinter import * jan = Tk() jan.geometry("500x500") jan.configure(background="#f0f0f0") head = PhotoImage(file =…
-
3
votes4
answers246
viewsHow do I organize each position on my list in ascending order?
This is my code: a = [[3,2,1],[4,3,2],[5,4,3]] for i in range(0, len(a)): for j in range(0, len(a[i])): a[i].sort() print(a) The problem is that it is only organizing the first position. Someone…
-
3
votes2
answers169
viewsHow do I delete empty lists from my list?
I have the following txt file: 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 6 8 9 3 4 5 6 7 7 8 8 9 1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 10 11 5 6 7 6 7 8 8 9 15 when opening it and generating a list of lists many…
-
3
votes2
answers454
viewsHow to clone a list with Python 3?
From list m: m = [[' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' # ', ' # ', ' # ', ' # ', ' # ', ' # '], [' #…
-
3
votes1
answer67
viewsDoubt: Function of generators
Write your own generator function which works as the internal enumerate function. Using the function thus: lessons = ["Why Python Programming", "Data Types and Operators", "Control Flow",…
-
3
votes1
answer948
viewsDetermine the key of a dictionary that contains the highest amount of values
animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']} animals['d'] = ['donkey'] animals['d'].append('dog') animals['d'].append('dingo') Be the dictionary animals defined above. The…
-
3
votes4
answers6351
viewsHow do I capture each key typed in python
I am trying to make a program that captures the keystrokes typed on the pc, so that later I can access them. I don’t know where to start. I don’t know if you use sqlite3 (database), in google I…
-
3
votes1
answer690
viewsWhat is the difference between classes initialized with (and without) __init___
I’m a beginner in Python and I wanted to understand a difference. The two classes below produce exactly the same result and the variables become public in the same way in both classes: class c(): t…
-
3
votes1
answer56
viewsGenerate new centered image at one point
I did a processing and found a point in the image that meets my criteria. I need to cut the original image into a smaller one (120x120) that has that center point. I tried to do the following: img =…
-
3
votes1
answer155
viewsSearch dates among other dates in Python
Good morning, I have a database on Mongo DB like this: { "_id" : ObjectId("5addb57d0043582d48ba898a"), "base" : "EUR", "date" : "2018-04-23", "rates" : { "BRL" : 4.175076 } { "_id" :…
-
3
votes1
answer5209
viewsHow to normalize data? Any sklearn library?
I need to normalize the data I have so that it stays between -1 and 1. I used Standardscaler, but the interval got longer. What other sklearn library could you use? There are several in sklearn, but…
-
3
votes1
answer425
viewsHow does Python handle static and dynamic variables?
Static variable, is the one where we separate the memory of the computer already defined beforehand (I read this in the book "Basic data structure"). The dynamic variable, on the other hand, is one…
-
3
votes3
answers183
viewsif and logical connectives
I need to find the fewer number and the second to smallest number of five typed numbers. But this strange fact is happening: #Subtrair o menor numero encontrado do numero digitado dif1 = n1 - menor…
-
3
votes1
answer170
viewsDifferences between __name__ and __qualname__
In Python functions/methods and classes have two attributes that in their most "basic" use seem to do exactly the same thing, are they: __name__ and __qualname__, see: def fn(): pass class…
-
3
votes2
answers434
viewsHow to create a counter in face detection?
As you can see in the code below, it only detects the faces with Haar Cascade, I would like to know how to display on the webcam the amount of people detected at the time. from __future__ import…
-
3
votes1
answer79
viewsAdd items within an array
I have the following array: soma_campos = null tabela = [ ['A-B', 22, 0.045, 0.1, 0.005], ['A-C', 50, 0.020, 0.1, 0.002], ['A-D', 48, 0.021, 0.1, 0.002], ['A-E', 29, 0.034, 0.1, 0.003] ] How can I…
pythonasked 6 years ago Sergio Sacchetti Junior 55 -
3
votes1
answer238
viewsSlicing String and Saving the Slices in a PYTHON List
Hello, I would like to understand a little more about strings in PYTHON. I’m developing a program, which consists of: Pick up a STRING Separate STRING from 3 to 3 characters And store each part in a…
-
3
votes1
answer3970
viewsCalculating minimum, maximum, mean and median in python
Error in calculating minimum: File "C:/Users/Administrador/Desktop/chicago_bikeshare_pt.py", line 273, in <module> assert round(min_trip) == 60, "TAREFA 9: min_trip com resultado errado!"…
pythonasked 6 years, 5 months ago Daniela Cristina de Jesus 39 -
3
votes1
answer1208
viewsMultiple users and authentication - Django
I am developing a project in Django that has two types of users: Client and Accountant. Each one is authentic and has keys that identify them differently. The Customer has as its primary key its…
-
3
votes1
answer84
viewsbs4: How to wrap an incomplete html code?
Hello, I came across incomplete html codes where are missing the tags "html" and "body". Follow the code I implemented: import bs4 content=''' <head> <title> my page </title>…
-
3
votes1
answer145
viewsReturn block-defined substring in Python on first occurrence
In python, I am trying to capture a block-defined substring, however the word "blocks" repeats in the text and I would like to get the substring up to the first occurrence of this. In this example…
-
3
votes3
answers871
viewsHow to separate characters from a string to a Python list?
How can I convert a string (a word, for example) into a list? entrada: a='carro' saída: ['c', 'a', 'r', 'r', 'o'] I know that by using split, turn into list gets the whole word, like to know if a…
-
3
votes2
answers154
viewsFlask and its contexts
I’m new to the desenvolvimento Web and I’m studying FLask and it has some objects that should only be manipulated in certain context as the Flask.g and the Flask.current_app what I can’t understand…
-
3
votes1
answer817
viewsHow to solve this encoding error (encoding error) in Pandas
I’m having trouble when python reads the xlsx with pandas. When it runs the des_pt = (f_pt.head()[pt][0]).encode('utf-8').strip() and puts the variable pt. Has an Encode problem because some…
-
3
votes1
answer169
viewsWhat does Transition band mean in band-pass filters?
Hello, I am working on a band pass filter in python, and while searching I found this link, which states a code variable: "b is the transition band also as a function of the sampling rate" What does…
-
3
votes2
answers937
viewsHow to save a chart to a PNG image?
I have some data from an experiment, and would like to save them as PNG. To display the data, I simply do the show(). However, I would like to save directly as PNG not to print the screen. How do I…
-
3
votes1
answer363
viewsScript execution error in python in Laravel controller
Currently my scripts work perfectly within Schedule that run at specific times within my server cron. The problem is occurring when I try to run the method inside the controller, this method…
-
3
votes1
answer31
viewsUse tuple with parentheses in Django query
I made a cursor to get the menus Parent of my application, then I want to iterate each menu Parent and get the menus associated with it. However, when passing the Parent parameter, the second course…
-
3
votes1
answer106
viewsClass definition within a function or another class
I’ve seen in some scripts definitions of classes within other classes or functions like this: class Grok(object): class Foo(object): ... ... What is the reason for this practice? It is only to not…
-
3
votes1
answer204
viewsType a word and return the word with uppercase vowels
vogais = 'a, e, i, o, u' palavra = str(input('Digite uma palavra: ')) if palavra.upper() in vogais: print(palavra) else: palavra Well, I did so but it didn’t work. I can’t do the program compare and…
-
3
votes1
answer1217
viewsGrouping table groupby pandas
I have a table in this format User Material Nota 1 youtube 5 2 facebook 4 3 facebook 3 4 facebook 5 6 youtube 2 7 orkut 3 8 twitter 4 and would like to group so that in the final table shows only…
-
3
votes3
answers4127
viewsCalling attributes of an object in another class in python
I’m a beginner in python and I wanted to know what I call attributes of another object in another class, because in Java, for example: package model; import java.util.ArrayList; import…