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
votes0
answers371
viewsPython session system
There is, in Python, a session system as exists in PHP? I need to do an access control for an application developed in Python that uses database. I have already developed a similar project (but web)…
-
1
votes1
answer78
viewsI need to use an array that’s in one code in another!
I have a project with the following files: old woman py. print py. need to use a 3x3 matrix that is in play.py in the print script.py print py. #função de impressão def impressao(): print(" Coluna 1…
pythonasked 7 years, 5 months ago Joel Medeiros 21 -
1
votes0
answers249
viewsHow to block user login with certain "status" in Django
I’m using Django 1.11 and class-based views. My user model is customized and in it I have a "status" field where it has "enabled, blocked and disabled". I would like to know how I can allow the…
-
1
votes2
answers3297
viewsIterate for with two variables
I have the following code: def hasPalin(string): begin = 0 end = len(string)-1 result = "" while(begin < len(string)/2): if (string[begin] == string[end]): result += string[begin] else: break…
pythonasked 7 years, 3 months ago Vinicius Macelai 364 -
1
votes1
answer2211
viewsClear string in Python (remove escape characters)
I came across some strings with the following content, example: "++++++//texto+++!!!+++//texto++++" I’m trying to find a method to clear the phrase but I’m not succeeding, someone could help me?…
pythonasked 7 years, 3 months ago Milton Teixeira 43 -
1
votes1
answer969
viewsGet path where python file is called
I created a python file and made it available to access from every place on the system, however, for many applications accurate the path where the python file was called by the system, but I did not…
-
1
votes1
answer11835
viewsSort Python Data Frame (Pandas) in two levels
I have this Dataframe and I want to organize it first by name and then by year, that is, Sort it in doís levels. How can I do that? Country Name Country Code Indicator Name Indicator Code Ano…
-
1
votes1
answer654
viewsHow to create variable names during code execution?
I need a little help. During the execution of a code I get a list with x entries (the size of the list varies according to the input). Each entry in this list is a line array with a certain number…
pythonasked 7 years, 3 months ago Luciano Magrini 29 -
1
votes2
answers2014
viewsHow do I read two columns of a . dat file in Python?
I have a file . dat with the following numbers: 34875 70.9300 -8.6700 54872 80.0500 16.2500 65456 77.0000 -5.5000 78787 78.2500 22.8300 20890 -8.9200 11.9300 87859 78.2500 15.4700 89556 80.6700…
-
1
votes1
answer24100
viewsInput numbers in the same line in python
I need to read three values in a single variable being the third with comma. Input: two data lines. In each row there will be 3 values, respectively two integers and a value with 2 decimal places.…
-
1
votes1
answer107
viewsStrange return when calling a function
I’m trying to do an exercise on functions, in Python, with the following statement: "Make a program that converts from 24-hour notation to 12-hour notation". Example: Convert 14:25 to 2:25 PM. The…
pythonasked 7 years, 5 months ago user158657 105 -
1
votes2
answers457
viewsWhy doesn’t my while work?
I’m studying repetition structure and in one of the exercises I had to check the sex typed, so I made the following code: sexo = input("digite m ou f: ") while sexo != 'f' or sexo != 'm': sexo =…
-
1
votes0
answers72
viewsGiving error Import at /post/new/ No module named 'blog.Forms'
In this line: C: Users Fer Gomes djangogirls mysite blog views.py in , line 5 the code from django.shortcuts import render from django.utils import timezone from .models import Post from…
-
1
votes1
answer46
viewsOpen files that will be shared between various functions, inside or outside the functions?
Next, I’m making a program that I’m going to divide between the function module and the interface, and I need to use files in this project (and I can’t use classes), it turns out I need to use these…
-
1
votes2
answers1443
viewsHow to make a nested FOR?
I’m opening two files, one is a text, and the other is a list. I want through nested check how many times each item in the list appears in the text. I did so: arquivo = open('texto.txt', 'r') lista…
-
1
votes2
answers70
viewsParse feed in Python
Access a feed whose layout is like this: <horoscope> <date>20170627</date> <listItem> <item> <signTitle begin="21/03" end="19/04">Áries</signTitle>…
-
1
votes2
answers82
viewsMy while closes before what really should
I made a code that should take the number of rows of a txt file and then use this same number of rows in a while to convert columns and rows into array. lines = 0 ln = 0 for line in dataset: line =…
-
1
votes1
answer487
viewsGet and Set using PROPERTY - Python3
As an apprenticeship of Property, created a small currency converter. See: class converteMoeda(): def __init__(self, dollar=0, real=0): self.dollar = dollar self.real = real def toDollar(self):…
-
1
votes2
answers2940
viewsHow do I import a jupyter notebook ? or open?
I am unable to import or open a file notebook.ipynb I tried to go to the file directory at the prompt and type : jupyter notebook filename And claims that the file is not found.…
pythonasked 7 years, 2 months ago Claudio Shigemi 119 -
1
votes2
answers5844
viewsPython/Pandas - How to create a data frame that contains the original line and duplicate line
In a date frame that contains two lines with Pais = India, I was able to create a duplicity-free data frame with only one line from India A data frame with duplicate line only I need to create a…
-
1
votes1
answer1838
viewsDivision between column values and rows using pandas
I created a table pivot containing some values, but I do not know if it is necessary to use pivot table in this case below is a sample of the results: Valor ajuste \ Data posicao 2017-05-30…
-
1
votes1
answer860
viewsTypeerror: can’t Multiply Sequence by non-int of type 'float'
I’m learning to program in python, but I came across a mistake in trying to develop the merge sort using object orientation. When calling the method sort() who belongs to the class MergeSort, the…
-
1
votes2
answers629
viewsHow to implement a priority queue that still meets other requirements?
I need to implement a priority queue, this queue in addition to the priority, needs to take into account some other requirements, such as switching between services and professionals, and of course…
-
1
votes1
answer968
viewsPython chart does not display all desired values
I would like only the values of the x, y coordinates corresponding to the points to appear in the graph. But it’s not like this: For example: The point whose x coordinate is 04/10/2017 09:41:00 does…
-
1
votes0
answers582
viewsCommunication between Python and Java
I am trying to create a client server application where the server will be written in python and the client in Java. The problem is that when you send a message from Java to Python the python server…
-
1
votes2
answers233
viewsClasses within classes (Python/Django)
Ola, I’m starting to study python on account of Django. I have a question that many may consider trivial but I don’t know the answer. I am building a Model with the following features: class…
-
1
votes1
answer425
viewsHow to sum a column of a file and visualize with . Plot(Kind = 'bar')?
I’m trying to sum up the column Duration ,and present using plot() trip_data['duration'].value_counts().plot(kind = 'bar') trip_data['duration'].count_data().plot(kind = 'bar')…
-
1
votes2
answers968
viewsPython 3.x Show typed data in an Entry on a Label only after pressing a button
I wanted to know the following; In my show, there’s: Entry1 -> where the user enters some information btn1 -> where it confirms the previously typed name and data is displayed on the console…
-
1
votes1
answer130
viewsError using a function outside the Python script
I created a function that uses other functions that are not in the same script, when running the program I find an error, stating that the function outside the script is not defined. All functions…
-
1
votes1
answer2425
viewsPython -> how to merge multiple csv files
I have 4 folders, and each of them is filled with csvs of 3 types (ap,peers,visits). I’m a beginner in python, but I wanted to create a python script that would merge the files that are peer, in…
-
1
votes0
answers365
viewsReceive user input using Django Class Based Views
If you need more information about the problem (urls.py, complete code of the template, etc.) just ask me to post, just not to pollute the post too much. General description of the problem: Update…
-
1
votes1
answer37
viewsAvoid Favicon Get in Flask
I have a client-server application in Flask, and when I get to the server, another get is done by asking for the favicon address. I wanted to know if you can not automatically do this favicon get.…
-
1
votes1
answer2076
viewsSelect an option from the Selenium Python drop down menu
I have a menu that presents several options, I want to select only the one that is active. When I give 'variable'. find_element_by_id('key') Selenium returns me ALL options. The active option has a…
-
1
votes1
answer474
viewsHow to give multiple python prints in the same place as the terminal?
Having the following code as the basis: for x in range(100): print("{}%".format (x)) How could it be done so that in place of each value appears in a different row and yes replaced in the same row.…
-
1
votes1
answer1149
viewsBrowse Python dictionary from the end
I wonder if there is a way to go through the keys of a dictionary backwards? For example, in a dictionary d1 ={1: [], 2: [], 3: [], ..} start with key 3. I know it is possible to go through from the…
-
1
votes2
answers2057
viewspython vector input
I have some input values of a matrix that will have the input of the following form: 1 2 3 4 2 3 4 0 so I’m trying to take the first line of m+n elements to turn everything into float, but it’s not…
-
1
votes1
answer526
viewsCreating directories in Python
I have a list of directories to be created that has this structure : Bla / Bla / Bla1.md Bla / Bla / Bla2.md Blu / Blue.md Ble.md But the archives .md should not be created, but the folders…
-
1
votes4
answers846
viewsHow to find numbers larger than X in a list
As an example, this code there N=[1,2,3,4,5] B= #quantidade de números maiores que 2 print(B) 'B' would be the number of numbers greater than 2 present in the list, for example.…
pythonasked 7 years, 2 months ago Caio Roberto 29 -
1
votes2
answers88
viewsOrganize string data flow by default
Friends, I am working on a scraping project. At some point, I capture a table on the screen in the shape of a giant string, more or less like this: list = ('0004434-48.2010 n EU n (30 working days)…
-
1
votes2
answers5626
viewsrecursiveness to find odd numbers in a python list
I would like to know how to use Python recursion to make a function that traverses all the odd notes from a list and add them to a new list Tested the code I got a null output. I ran the Debugger…
-
1
votes2
answers11713
viewsHow do I make python read line by line?
Let’s assume I have a txt file, with some data: [File.txt] Oie Olá Tudo bem? I want something (in python) that reads line by line and prints(print).
-
1
votes1
answer461
viewsStore binary variable in list mode
How can I store the binary variable in horizontal line type list mode with all the values coming out in the binary variable. for n in receivedMessage: contador += 1 print (contador)…
pythonasked 7 years, 2 months ago Sergio Nunes 351 -
1
votes1
answer1156
viewskeep only rows of a column with the value with Pandas
Hello, I’m a beginner in the area and one of the exercises I’m having trouble answering is this. there is a file with several columns. In one of these columns, there are several cep(zipcode), and…
-
1
votes2
answers2148
viewsGenerate random numbers without repeating the previously generated number
I am trying to make a program that simulates the game "Door of Hope" of Silvio Santos in Pyton and I need the program to generate a random number, excluding the number previously generated. I did it…
-
1
votes0
answers78
viewsVariable not defined
My code gives me an error in a definition of a variable but I think it is declared the variable bits_rx, this variable aims at the result of the conversion: while(1): while not radio.available(0):…
-
1
votes0
answers45
viewsHow do libreoffice interpret the - signal sent by python program?
Hello, I’m trying to use worksheet.write_formula(row,col+5,'=B%d-E1'%(row+1)) to write a formula in CALC, but the minus sign seems to be misinterpreted in Libreoffice and it is necessary that I…
-
1
votes1
answer941
viewsHow to use both versions of anaconda on linux?
Good afternoon guys, I’m studying python for projects and I was recommended to use the anaconda package. I am a linux user (Ubuntu) and have therefore installed the two packages on my system.…
-
1
votes0
answers41
viewshow to run eprimer3 via terminal and via biopython? there is no problem with the code, but rather with the eprimer3 command. Suggestions?
nemias@debian:/$ python Python 2.7.9 (default, Aug 13 2016, 16:41:35) [GCC 4.9.2] on Linux2 Type "help", "copyright", "Credits" or "License" for more information. import Bio from…
pythonasked 7 years, 4 months ago Neemias da Silva Santos 11 -
1
votes0
answers116
viewsPipe() command in windows
I’m trying a simple communication between processes, but the son f_filho is not receiving the message sent by the father. How to solve? # -*- coding: cp1252 -*- from multiprocessing import…
-
1
votes2
answers409
viewsreturning python list indexes
I’m having a problem on the line index, because it does not accept float. But how can I get around it? def median(numbers): numbers.sort()#The sort method sorts a list directly, rather than…