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
answer118
viewsMultiprocessing or Multithreading
Good people, recommend what to optimize code? multiprocessing or multithreading? the script is running in series, but has several for in series. Complete code: https://pastebin.com/WtD6XbVT…
-
0
votes4
answers1471
viewsGenerate random numbers and add them up
I wish I could make the script generate "n" numbers(so far everything is done as you can see in the code below) and add them up. import random n = 2 total = (random.randint(1, 100), n) print total…
pythonasked 7 years, 4 months ago Gonçalo Lobo 11 -
0
votes1
answer414
viewsScrapy Web Data Extraction
Up.. Next guys... I’m writing code with scrapy framework to search and extract some data. I’m new at this! The code to follow theoretically would have to search and extract, but it does not extract…
-
0
votes1
answer912
viewsTake off or move a frame in Tkinter(python)?
I have a problem in python code that is the following, type I want to move the frame of the entry checkbutton so I can not, if you can help me, run the code there for you to understand the problem.…
-
0
votes1
answer978
viewsDetermine the largest prime number after a value is given using while function
I have to create an exercise to discover the largest prime number after being provided me a certain value using the while function, which is wrong in what I created below?? def maior_primo(n): x=0…
-
0
votes1
answer309
viewsIs there a tag in Django to show part of the text?
I wonder if there is a tag to show part of a description {{ post.description | tag-aqui }}
-
0
votes1
answer1130
viewsPick an item from a list
Good morning, I’ve been trying to make a mini game, where I insert the words in the variable WORDS and the same type the name randomly, so far Ok. But I wanted to change and I’m not able to do what…
-
0
votes0
answers284
viewsError from scapy.all import *
I’m trying to mess with Scapy but when I try to use him from scapy.all import this error appears. from scapy.all import * Traceback (most recent call last): File "<stdin>", line 1, in…
pythonasked 7 years, 6 months ago Lucas Chaves 1 -
0
votes2
answers1459
viewsDelete and Query Python function
I have to make a simple program in Python. In the case of a library , however I’m having difficulties in the function of consulting and deleting. I honestly stalled, tried a lot of different ways…
-
0
votes2
answers439
viewsPython graph does not display values correctly
I’m trying to learn how to make graphics in Python. I made one now and it didn’t get very good: All dates are on April 10, 2017, coming only the time from 07h50:00 until 08h40:00 (GMT -3h) In the…
-
0
votes0
answers45
viewsData entered into Sqlite3 is not shown in the Pyqt4 application
I made a small Pyqt4 desktop application where I insert data in db sqlite3, but when I go to consult this data that was inserted previously, they are not on the display screen of them, only when I…
-
0
votes1
answer149
viewsI made a very simple game in Python but it goes into an infinite loop, could someone please help me with this?
#jogo do adivinha# resp = 1 i = 5 x = 0 print ("Tente adivinhar o Número que eu estou pensando.") print ("Você só tem 5 chances e o número está entre 0 e 100.") while resp != 0: print ("") try:…
-
0
votes1
answer379
viewsIs it possible to use pyad (active directory module) on linux?
If it is possible to use this module on linux, would you like to know how to install it? tried with "Pip install pyad", but I get the message below: Could not find a version that satisfies the…
-
0
votes0
answers218
viewsCompile py code for exe
I need to compile the script in python to make it . exe, but only with the pure Python kernel, which does not have most of the libraries I used to develop. The kernel I use for development, is…
-
0
votes1
answer61
viewsUse of the set and for function in the same structure
I am studying data science through the Python language and came across the following code: world_trends_set = set([trend['name'] for trend in world_trends[0]['trends']]) us_trends_set =…
-
0
votes1
answer2905
viewsSegment image and highlight object border using python
I’m testing some algorithms to improve the image quality that my hardware is getting. I have in the image a pick and I would like to highlight the object contained in it. I used the code below to…
-
0
votes1
answer195
viewsError file path to run mp3
I was solving a proposed exercise in a course that consisted of running an mp3 file passing the path of it, I searched a little and I arrived at this code: from playsound import playsound…
-
0
votes1
answer973
viewsConnect via SSH to another machine and run script
I am automating tasks and I am new in Python, so I would like your help because I need to run a Shell script on another machine and this command I need to give inside a Python code. I thought I’d…
-
0
votes0
answers31
viewsHow to open a program as admin in Python
Guys I wanted to make a script that opens cmd as admin and type a command (for example ipconfig).
-
0
votes1
answer666
viewsWord processing in csv file
I have a database with over a thousand opinions (text) in a csv file, however I need only texts that contain more than 5 words to stay in my file. The problem is to make a code that goes through the…
-
0
votes1
answer407
viewsFilter data from a string with regular expression
I have a variable that contains the full company name and CNPJ. I am using verificaCnpj = re.search("\d{2}.\d{3}.\d{3}/\d{4}-\d{2}", variavel) to locate the CNPJ (because there are other variables…
-
0
votes1
answer1866
viewsDecompose the value of a Python banknote
I need to read an integer value and calculate the fewest possible banknotes (ballots) in which the value can be decomposed. Banknotes considered are 100, 50, 20, 10, 5, 2 and 1. And dps print the…
-
0
votes1
answer809
viewsRun python kivy file
I’m doing a crud maintenance using python/kivy. It’s four main files, one for table P, one for A, and one for C. The fourth main file is the main screen that will have three buttons for you to…
-
0
votes0
answers47
viewsHow do I deactivate Focus in a window even if I click it?
I am programming a virtual keyboard, where I will type by clicking the mouse. In python2.7 interface Qt4 I’ve been able to solve the idea enough, I’ve been able to make him keep showing up, and also…
-
0
votes1
answer365
viewsHow to create an SQL function that calls a script in python?
I need to create a software that at each insertion in a table a python script detects that there has been a change in this table and execute certain commands. I have done an implementation that is…
-
0
votes2
answers4702
viewsHow to convert date difference from seconds to hours/days?
I made a little program in python that he takes the current time, the time, convert in seconds and subtract from each other to know the difference between him. My doubt is, how do I convert these…
-
0
votes1
answer611
viewsUsing an external folder function
I have the following situation: Within the Pasta1\ i have a file that is my main code This file codigo_principal.py reads a file that is in a subfolder within the Pasta1\ I also have another folder,…
pythonasked 7 years, 5 months ago José Henrique Luckmann 1,084 -
0
votes6
answers7088
viewsIntersection between two sets (element that is in set A and B at the same time)
I’m trying to make a function that returns the intersection between two sets: def intersecao(conjuntoA, conjuntoB): inter = [x for x in range(1,12) if x in conjuntoA and conjuntoB] return inter a =…
-
0
votes0
answers50
viewsInvert Number
What logic could I employ to make a program where I insert a number and then be reversed. ex: 123 to 321 PS: has to be a function.
-
0
votes1
answer266
viewsWhat would the conversion of this algorithm from C to Python look like
unsigned char CheckSum(unsigned char *uBuff, unsigned char uBuffLen){ unsigned char i, uSum=0; for(i=0; i < uBuffLen; i++){ uSum = uSum + uBuff[i]; } uSum = (~uSum) +…
-
0
votes1
answer1027
viewsPrint Format & End in Python
I’m creating an application that connects to db Sqlite, query and returns the column of the table in question, the problem is that the returned result without formatting comes like this : ( u'Field…
-
0
votes2
answers1856
viewslist index out of range Python
I have lists with numbers in string format and empty spaces. First I want to take the empty spaces, and then I want to convert to float. But right on the first for error appears: if (x[i]=='' or…
-
0
votes1
answer2986
viewsFree API for Weather History
As I explained to Guilherme in the comments, I make it very clear in my question that I want a climatological HISTORY. The question indicated as duplicate does NOT show how to recover climatological…
-
0
votes1
answer959
viewsSort dictionary by value and use rule if value is first python
I want to make a dictionary in python in which you will get diseases and scores ex: dic['alzhelmer']=3 dic['flu']=5 The program should put in order the diseases that scored the most for those who…
-
0
votes1
answer100
viewsParameter in page URL
Dear, I need to create a Pyramid application for use of API. 1 - "/Quotes/< quote_number>" - Present page containing the quote returned by the API corresponding to < quote_number >. I…
-
0
votes1
answer247
viewsFfmpeg and video vs audio time
I am with a simple application that performs the download of a video + audio and ' concatenate ' ( Join ) the same with the tool Ffmpeg, the problem is that most of the time the user will download a…
-
0
votes0
answers228
viewsSubprocess & call in Python ( Security )
Developing a simple application, some code analysis tools gave me the following warning : Consider possible security implications Associated with call module. For that particular code snippet : from…
-
0
votes1
answer816
viewsTransfer file to linux server with Python
Hello, I’m looking to make a file Python that transfers all files from a local folder in my Windows for a specific path on my server Centos 7. At first that server is in my local network, but it…
-
0
votes5
answers9375
viewsProgram to find MMC in Python
I was doing a basic exercise for the function While, he asked to create a program that found the MMC between 2 numbers... I managed to do, but the program continues to print the answer non-stop on…
-
0
votes1
answer629
viewsPython 2.7: Program does not run
Hello, My program is no longer running, it used to work normally but then just doesn’t work. I checked that the program does not cross the line "Reload(sys)". # -*- coding: cp1252 -*- from gtts…
pythonasked 7 years, 4 months ago Kaike Wesley Reis 35 -
0
votes0
answers25
viewsconversion of Unittest Python2 to Python3
I have some free time and am updating in Python3. I came across a problem in the execution of the unittest, and I believe you can help me. Error: File…
-
0
votes0
answers486
viewsOpen files through the relative directory
How do I read the relative file path that is in a different python file directory and then open that file? For example: For archive1 in the name_project/files/file1.txt directory and the python code…
-
0
votes1
answer45
viewsHow to get data from a specific web page?
I aim to create a script that gets data like bugs,issues among others from the following page of Spring Framework, unfortunately I have no code to show because in fact I do not have much idea of how…
-
0
votes1
answer77
viewsFindall using Elementtree does not return expected result
I am trying to find a specific element within a python XML file. I use Elementtree for this. The following code: root = ET.fromstring(response.content.decode('utf-8')) print(root.findall('.//*'))…
-
0
votes1
answer845
viewsAutomate reading multiple text files in a Python script
I have a Python script that counts the number of connections contained in a text file and that is working perfectly: with open('1zao.txt') as f: linhas = f.readlines() soma = 0 for linha in linhas:…
-
0
votes0
answers213
viewsDjango Error - Unicode Decode Error
When trying to create an App in Django with the command django-admin.py startapp Name, such command raises the following error : Traceback (most recent call last): File "manage.py", line 22, in…
-
0
votes1
answer2840
viewsSending files through sockets - Python
I’m studying sockets, using Python, and tried to make a script to send (Server) and receive (Client) files through sockets. However the script does not work as expected, the final file (received by…
-
0
votes1
answer1333
viewsError creating python mkvirtualenv virtual environment 3.6
After installing python 3.6 and then virtualenvwrapper via Pip (Pip install virtualenvwrapper-win), I tried to create a virtual environment by the "mkvirtualenv name" command and the following error…
-
0
votes1
answer284
viewsImport Python DLL into C++
How do I compile a Python class in DLL in order to import it into C++, using Python features that are not available in C++? I want to be able to import it without having Python installed on the…
-
0
votes1
answer685
viewsRegistration without duplicity in Sqlite
I was able to avoid the double record of romaneio(nr_roman), but I made several attempts to do the same with the plaqueta(plaq),so that if the platelet already exists in the database, it persists in…