Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
1
votes1
answer99
viewsDjango 1.11. Serving robots.txt, sitemap, etc.
I need to know how to serve these files that usually go to the root of the project. I’m making a route for each of them in the.py urls file but it doesn’t seem the right way. What’s the right way?…
-
1
votes1
answer992
viewsHow to write a . csv file in Python including file settings?
How can I create a csv file containing column width information and configured header and things like that, is it possible? or we can only write the data without any configuration?
-
1
votes1
answer296
viewsWhere is the source code of the Python3 commands located?
Where is the source code for the Python3 commands? I want to see the source code for the commands as len(), count(), find(), etc etc. I use Linux Mint, I’ve looked and looked, but I don’t think...…
-
1
votes1
answer28
viewsCross valdation n-fold
W1 W2 W3 W4 A/N 0 0.543405 0.278369 0.424518 0.844776 1 1 0.121569 0.670749 0.825853 0.136707 1 2 0.891322 0.209202 0.185328 0.108377 1 3 0.978624 0.811683 0.171941 0.816225 0 4 0.431704 0.940030…
-
1
votes1
answer393
viewsHow to remove null, false and true values from Json file?
I have a JSON file with this data: { "in_reply_to_screen_name": null, "favorited": false, "id_str": "92", "entities": { "user_mentions": [], "symbols": [], "urls": [], "hashtags": [ { "indices":…
-
1
votes1
answer39
viewsPython c/ swapcaser problem
The program must convert a letter in schema A->a or a->A and works normally, except that at the end of the string a None appears. Does anyone know how I can get it out? def swap_case(s): for x…
-
1
votes2
answers13897
viewsHow to remove specific position characters from a string?
I have a string read from a file that contains a data and the special new line character ' n'. Example: dado = 'teste \n' First I check the size of the string, then I can remove the last two…
-
1
votes1
answer478
viewsPassing string to team
I’m taking 2 strings in the format hh:mm:ss to then calculate the time spent between them in days, hours, minutes and seconds format. I have already split and have all fields separated into their…
-
1
votes1
answer33
viewsDictionary running all keys instead of just one
I have in the following code I have a function that performs certain operation according to the parameters passed. Then I have a dictionary serving as switch case, which will serve to define which…
-
1
votes1
answer604
viewsHow to integrate and make queries with pymongo?
I am learning to integrate Python and Mongodb and, because of that, I proposed a challenge: create a small program to register football players. My program has two modules, info_player and…
-
1
votes1
answer1914
viewsPassing a list of objects to a python dictionary
I have a list of objects: lista_objetos = ['acarreta', 'afeta', 'alavancagem', 'apropriadas', 'arvore', 'avaliacao'] each object stores information, among that information the word itself, Ex:…
-
1
votes1
answer2885
viewsHow to open a Python file selection window with GTK?
I have a Python application using GTK graphical user interface. This interface consists of a screen with data input a button, the goal of the program is to save data in spreadsheets in a specific…
-
1
votes1
answer1599
viewsList manipulation with dictionary inside a Python loop
I have a list of lists, in which the internal lists contain words and each internal list represents the words of each different file. lista = [['carro','barco'],['moto','aviao'],['bike','skate']] ie…
-
1
votes2
answers1152
viewsSquare Matrix in Python 3
My code is printing spaces at the beginning and end of the line, and is giving presentation error (URI issue 1557) Does anyone have a good tip? "Matrix values should be formatted in a…
-
1
votes2
answers1697
viewsDoubt Random.shuffle() returns None(inside print)
Because when random.shuffle() used inside the string returns None? I found out after you can use shuffle get off the print and put in a single line but did not understand why it lock. Sample code…
python-3.xasked 6 years, 8 months ago kdz 31 -
1
votes0
answers54
viewsIdentify combobox items and play in for loop using Selenium JS and Python
I need to do a for loop to open an x number of tabs and each tab uses a different "Dashboard". The first part I’ve done how could I do the second? Remembering preferably with Xpath using JS and…
-
1
votes1
answer3056
views"list indices must be integers or Slices, not Nonetype"
I’m trying to develop an old game in python, which gets a user who will play against the computer, the output should say the winner of the game or got old. Almost everything is correct except when…
-
1
votes0
answers56
viewsHow to check connected tty ports in Python?
I have a device that is connected to the computer and I need to verify which devices are connected and information about the device, to then take the name of the port and initiate a communication.…
-
1
votes0
answers27
viewsHow to generate Factory Boy Fuzzy Attribute before running each test?
I am creating unit tests to perform integration tests of my web application. The tools I am using are: Mongomock to create a temporary bank instance for testing and Factory Boy to create mock…
-
1
votes1
answer15660
viewsPython, ascending order of numbers
My goal in the code is to print an increasing order of integers. For example: User type 2 numbers and I want to print the ascending order. Ex.: n1 = int(input('Digite um número')) #O usuário digitou…
-
1
votes3
answers2049
viewsHow to start full screen window with Tkinter?
from caixaimport import * # Variables # Tkinter Variables win_width, win_height = 1280, 1024 windows = Tk() # start a variable Tk windows.geometry(f'{win_width}x{win_height}') windows.title('SCH…
-
1
votes1
answer143
viewsParse numerical set for sequential numbers
I have, small part, of the data below, sequence of numbers: a = [(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 19, 20, 23, 24, 25),(1, 2, 3, 4, 10, 11, 12,…
-
1
votes1
answer2073
viewsHow do I make a 2°degree equation graph using Python?
I made a code that calculates Bhaskara for me and I was thinking of making this program show the graph of the equation as well, but I don’t know how to do that. if anyone knows how to do this,…
-
1
votes0
answers258
viewsLimiting the response time of a function
I did a script on python 3 that performs speed tests on my internet every 60 seconds and writes these results in a file .txt. Within this script I have a function called get_results which is the…
-
1
votes1
answer2967
viewsFigure Legends
I would like to know why a marker in the 2dB column on the 10 0 line appears in the image and how I can eliminate that without erasing the markers on the blue line, which is what I want? The code to…
-
1
votes1
answer1300
viewsExchange of information between Python classes
How can I exchange information between two different classes? I need to pass data from one to the other. Each class is running in a different process. An example of the structure, the code is too…
-
1
votes1
answer71
viewsWhat is the right way to do the template in Django/python?
This has been my first contact with the framework and with mvc/mvt, and I’m in doubt, as a matter of good practices and tals, should I make a template for each of the views or should I just make a…
-
1
votes1
answer3482
viewsSend POST form with python
I am developing an API in my work, and I need to develop something in python2 that sends a form to the server through the POST, I saw some questions here on the forum and I could not find anything…
-
1
votes1
answer252
viewsType error: not all strings converted during formatting
I’m trying to make a match or a match. The problem is that every time the sum of my move and that of the computer is 'even' this error message appears. I have tried other types of formatting and…
-
1
votes0
answers245
viewsExtract names and import into an excel spreadsheet
I need to read files TXT and remove from them names of persons and their respective "functions" of the text. They are minutes of hearing, where I need to find the name of the parties (Plaintiff and…
-
1
votes2
answers690
viewsSubmit form in python
I’m trying to submit a form on the website https://www.loskatchorros.com.br/ucp/login.php ,but I’ve searched several ways here on stackoverflow how to submit a form, and found no way to solve this…
-
1
votes2
answers778
viewsDoubt about the Slice function
To the answer back that one question that the Guilherme Nascimento P. did, opened up a doubt on the use of the function slice, until the moment I had no knowledge of it, and to find it in the…
-
1
votes2
answers421
viewsDoubts of python
I’m new to python, and I’m looking to make a system, where you fill out a questionnaire, and consequently it already prints in html to just paste in the forum. What I rode was the following: from…
-
1
votes0
answers589
viewsPython3.5 - Import multiple files from one folder
I have the following code: __author__ = 'Jones_Santos' # !/usr/bin/python3 import os from __init__ import mycursor, connection import csv import os from datetime import datetime, date, timedelta,…
-
1
votes2
answers1944
viewsHow to repeat a code?
Hello I am new in python and I would like to know with respect the code soon after its termination. Since there are several If and Else in the code. Just in case here’s my code. print ("\n\t…
-
1
votes1
answer781
viewsSize of Binary Tree
I need to develop a method to calculate the size of a Binary Tree but I’m getting compiler error. Code: class No: def __init__(self, dado): self.esq = None self.dir = None self.dado = dado class…
-
1
votes2
answers116
viewsSorting algorithm not working!
""" Arrange the elements of a list in ascending order """ #ordenação bolha #L = [5,3,1,2,4] L = [7,4,3,12,8] x = 0 while x < (len(L) -1): if L[x] > L[x+1]: L[x],L[x+1] = L[x+1],L[x] x += 1…
-
1
votes2
answers364
viewsLogic to get the lowest user read value
What’s wrong with my logic? I can’t return the smallest value def menor(size): size = size vet = [0] * size menor = 0 for i in range(size): vet[i] = int(input('Digite os valores: ')) if vet[i] >…
-
1
votes1
answer851
viewsPython pandas formatting
import numpy as np import pandas as pd ID = [i for i in range(1,101)] def tabela(imc): if imc < 18.5: return 'Abaixo do peso' elif imc < 25 and imc >= 18.5: return 'Saudável' elif imc <…
-
1
votes1
answer153
viewsProgram to pick up on a web page events
source code here too: https://pastebin.com/DesqWJfY Objective: to catch events in http://www.bhaktiyogapura.com/2018/03/calendario-vaisnava-marco-2018/ Each month, the URL changes only the fine, for…
-
1
votes0
answers37
viewsGrouping of dataframe with sorting
I’m having a hard time, and I don’t know how else to move on. I have a Dataframe where I am doing a grouping for some columns and in the Aggregate of it I take one of these columns and use the size…
python-3.xasked 6 years, 7 months ago Flavio Guilherme 11 -
1
votes1
answer98
viewsWhat signal to use for firing methods from a pygtk thread?
I have a Tree View that I need popular with data obtained in a thread, but if I do it from it the program presents several random problems and errors. Researching found that the ideal is to trigger…
-
1
votes1
answer1502
viewsHow to print an element from a list of lists in python
I have a list of lists, like: [ ('name1',size1), ('Nome2', size2)] I want to print just the name of each list, how could I do it?
-
1
votes3
answers1877
viewsList a range of numbers and add one by one
I am with this doubt I do not know how to start, I wonder how could I do to add a number with another of a range for example: 2 = 2 3 = 5 4 = 11 And so on I’m not succeeding, if anyone can help me…
-
1
votes1
answer1870
viewsHow to save the result to a file?
Well, I’m doing a program that takes the spaces of sentences, letters, words, and puts each "phrase/letter/word" under each other. For example: A "phrase/letter/word": BAB BBA ACA AAB BCB CBB ABC…
python-3.xasked 6 years, 9 months ago BRKappa 41 -
1
votes1
answer1126
viewsUnicode Error: 'utf-8' codec can’t Decode byte when installing rpy2 with Pip
I’m trying to install rpy2 which is a package to run R language in python, but gives the error: $ pip install rpy2 < Using cached rpy2-2.9.2.tar.gz Exception: Traceback (most recent call last):…
-
1
votes1
answer2280
viewsChange colors in program using Tkinter
hello, I need to create a function or maybe two to change the background color of the main window without interfering with subsequent events. wanted to add in the menu feramentas>environment:…
-
1
votes1
answer174
viewsGenerating functions: What are the advantages of using them?
Generating function: def geraQuadrados(n): for i in range(n): yield i**2 for i in geraQuadrados(5): print(i) no generating function: def novosQuadrados(n): l = [] for i in range(n): l.append(i**2)…
-
1
votes1
answer82
viewsCan someone please explain some of that code to me?
The code in question is the bottom one, a lot of it I’m understanding more the loop for confused me, it gets the sequence of the variable, but in print, it informs exactly the sequence that the user…
-
1
votes1
answer130
viewsHow to open a csv created in Python without opening an import screen?
I have created a Python csv in several ways as can be seen below, but every time I open the file opens the import screen as below. Why does this happen? And how can I make the file open directly,…