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
answer106
viewsTraversing a file and splitting its contents into other separate files using Python
from scapy.all import * pkts = rdpcap("lalalao2.pcap") #time slice de t em segundos : 10 minutos t = 600 somaMin = pkts[0].time + t valores=[] for p in pkts: if p<=somaMin: valores.append(p)…
-
0
votes1
answer253
viewsWhy can’t Tkinter execute a 'simple command'?
I would like to understand why in the code below the tikinter (I think this is the problem) can not execute something simple like 'c = c + 1' ? Code: from tkinter import * import pygame.mixer sounds…
-
0
votes1
answer986
viewsHow do I use the find function to find an entry in a Python dictionary (json)?
How to use the function find to search for a dictionary entry in Python (json)? Should I use json (loads) and json (dumps)? If I type, for example, "ma" the search result would show me "Cesar…
-
0
votes2
answers328
viewshow to make the time appear in the window(label)?
I have the following "timer" code, but it does not appear in the window, only in the Python 3.6 console. How to make it be printed in the window? (Obs.: the window only opens when the preset time is…
-
0
votes2
answers241
viewsCheck continence python list
I’d like help with a code. lista1 = [5, 6, 7] lista2 = [4, 'a', 9, 5, 6, 7] Check if the list 1 (the whole list) is contained in Lista2 and if lista2 = [4, 9, 5, 'a', 6, 7] do the same check, but…
-
0
votes1
answer72
viewsI can not run this giving error of indexing what is wrong
def main(): q = Queue() i=1 while(q.isFull()==False): digitado = input ("digite um numero para inserir na fila: ") numLido = int(digitado) …
pythonasked 7 years, 8 months ago Eliano Almeida 1 -
0
votes0
answers108
viewsExtracting source and destination IP to check if the server has become inoperative after attack
from scapy.all import * from collections import deque def print_attack_measure(pcap_file): plist = rdpcap(pcap_file) server_ip = "192.168.1.5" n = 300 d = deque(maxlen=n) # If you want…
-
0
votes1
answer163
viewsPython Source with subprocess
I’m trying to run a command line on the terminal through a python script. The command line is as follows: vcftools --vcf <arquivo.vcf> --extract-FORMAT-info GT --out <arquivo sem…
-
0
votes1
answer96
viewsAverage True Range Calculation
I have the following problem: I performed the calculation of ATR (Average True Range) using numpy library, there was no code problem (exception, etc...) however, the result shows a small decimal…
-
0
votes1
answer290
viewsSimple example of p2p blockchain in python, anyone?
Hello, I am interested in blockchain technology to track origin of products to prevent fraud (imported drinks). Someone would have examples and how to start in python. thanks.
-
0
votes1
answer673
viewsScript to take page data in Php or python
I want to implement a script that accesses the printer page here of my work and take the data as for example, number of impressions, user names, basically I want to create a control system. Where I…
-
0
votes2
answers495
viewsPython takes the first column value instead of the last one
I’m trying to get the last record of a column in Mysql but Python only returns "1", is an ID record with auto_incriment. I tried several ways, in some I was returned the whole column, in other era…
-
0
votes0
answers35
viewsHow to insert Weather Underground forecast icons
Good afternoon I’m trying to insert the Weather Underground icons but no Python 3 icons. Below I leave a part of the code. url =…
-
0
votes1
answer742
viewsConverting a text file to XML with Python
Imagine I have the following command: echo -e "`date`\n\n`free`\n\n`vmstat`\n" >> free_vmstat_output.txt the generated file (the output of the above command) would be (in TEXT mode): Fri Mar…
-
0
votes4
answers457
views4x4 matrix with 20 elements
Galera made a code in Python whose exercise asked to make a 4x4 matrix , show the amount of elements larger than 10 and show the final matrix. I did and everything was fine only that the matrix ta…
-
0
votes1
answer167
viewsSocket-python syntax error
except socket.error, (errno, msg): if errno == 1: # Operation not permitted msg = msg + ( " - Note that ICMP messages can only be sent from processes" " running as root." ) raise socket.error(msg)…
-
0
votes6
answers14517
viewsHow to define the largest prime number within a given number?
For example, you give the number 100 and the highest prime number within 100 is 97. How can I program this? "Write the maior_prime function that takes an integer number greater than or equal to 2 as…
-
0
votes1
answer248
viewsList empty after python loop
Hello, I have the following code that does this: It will traverse a vector that has a certain set of elements (residuo) with the same ID ([1][1][1][2][2] for example) and then store all elements of…
-
0
votes1
answer1049
viewsInstall Module openalpr
Good evening developers. I need to download a module for Python, but I’m not getting it, I looked on the internet and mainly on Stackoverflow in English, but nothing helped, if anyone can help me I…
-
0
votes2
answers1123
viewsProblem with lists - Python
I can’t do: Ages and heights of 5 students were noted. Do a Program to determine how many students over 13 are tall lower than the average height of such pupils. Final Code: idadeAlunos =…
-
0
votes2
answers8348
viewsSum of elements in lists
[[3, 2, 7], [8, -2, 5], [-1, 4, 3], [2, 2, -9]] Then it stores in three distinct variables, ignoring the negative values, the sum of the elements separately. That is, the sum of the first element of…
-
0
votes0
answers774
viewsAttributeerror: 'Nonetype' Object has no attribute '_product'
I’m trying to do a project with Python and Docker, but I’m having some programming problems. I have 2 error files that are Provisionops.py and Dockerops.py. Follow the Provisionops.py…
-
0
votes1
answer183
viewsHow to search within Python code
Hello, I would like to make a code that when I typed for example, "product name", it checked if there is any word with the name I typed and returned a value, example "200 real". But I have no idea…
-
0
votes1
answer244
viewsHow to keep a fixed value within a recursive function?
I would like to create a variable with the first value passed as parameter in a function, but every time a recursive call is made the variable receives the value of the new parameter passed. For…
-
0
votes1
answer31
viewsMakefile does not work on MINGW64. Can anyone help me?
I’m programming in python in Django with Sublime Text 3, using Git Bash MINGW64. I created the Makefile but when I run I get "bash: make: command not found"
-
0
votes2
answers52
viewsTransform long/varchar data to string
# -*- coding: utf-8 -*- import MySQLdb as mdb import matplotlib.pyplot as plt print(plt) con = mdb.connect('localhost', 'root', '123456', 'testdb'); null = None with con: cur = con.cursor() d =…
-
0
votes1
answer193
viewsPython and Django online course creation platform
I’m building a platform for creating online courses, and I’m using Python and Django. I would like to know whether there are already libraries in Django for this purpose. An example I’m using is the…
-
0
votes0
answers1384
viewsNIM game - PYTHON
My question wasn’t so clear last time, so I decided to redo it here, and I think I know where I’m going wrong, but I don’t know what I’m going wrong. In the question it says: "You must write a…
-
0
votes2
answers1885
viewsHow to create a board of user-determined size and present it as text using python?
I am trying to create a program in Python 3.6.1 that creates a board according to the size typed by the end user and prints the result in the shell. It needs to be presented as text, and cannot use…
-
0
votes1
answer10442
viewsHow do I import Python image with the Tkinter GUI?
How to place an image in the Tkinter library widget?
-
0
votes2
answers100
viewsArduino restarting when starting python code execution
I am new in the development part and mainly in using the Arduino. I am developing a python web application with some functions, one of them is to turn a light bulb on and off (my problem). I…
-
0
votes2
answers1417
viewsFind the highest value of any python file
Good night Devs! I am having certain difficulties in manipulating python files. I have a TXT file with float numbers. Example: numbers.txt 10 130 20 77 23 9 10 20.26 -20.26 2 Having this data in…
-
0
votes1
answer741
viewsCreate dataframe tuples generated by Pandas
Is it possible to generate a tuple that stores the values of the lines of a dataframe generated by pandas? I uploaded the values of a CSV file to a dataframe, now I need to perform some calculations…
-
0
votes1
answer154
viewsWhat Method to Send Email in Python?
for row in values: # Separei os valores da data em 3 variaveis temp. year = int(row[0][6:10]) moth = int(row[0][0:2]) day = int(row[0][3:5]) if day == d1.day and moth == d1.month and year ==…
-
0
votes1
answer262
viewsWord processing
I have the following scenario: I have a variable with a text inside. I separate this text by words inside a array, With this I need to validate how many times each word appears in the text. I…
pythonasked 7 years, 5 months ago Jhonatan Teodoro 33 -
0
votes1
answer445
viewsHelp python by taking only the last data from the list
I have a website and I need a name separation system:last name with list, the data is in a txt and I normally import the data is for example: maria:Carla Joao:lima wanted to be able to separate as…
-
0
votes1
answer893
viewsHow to increment number from a button click
I want a button that adds ''+1 'to the label that is displayed in the tkinter, but I do not know very well how to do, and I found nothing on Google, what I understood does not return what I wanted,…
pythonasked 7 years, 7 months ago Edilei Zamarioli 5 -
0
votes0
answers232
viewsPython + Django list + HTML select option
Good morning guys, I need your help with a code I’m developing in python + Django Here’s my problem: I have a function in views.py in which you select a Name in the client table and place the…
-
0
votes1
answer78
viewsSame code producing distinct results in Codeenvy and Windows 8.1
I had made the following code in codevy.io and Python installed in codenvy is 3.5.1. I took this code and put to run in windows 8 with python 3.6.1. The purpose of the code is to clean some CSV…
-
0
votes1
answer39
viewsError compiling Caffe/Pycaffe
I’m trying to compile Caffe on an Ubuntu 14.04, but I keep getting the following error: /usr/bin/ld: cannot find -lboost_python-py35 /usr/bin/ld: cannot find -lpython3.5m collect2: error: ld…
-
0
votes1
answer45
views"Missing Scheme" error using Scrapy
When I run my spider scrapy returns me the following error: Valueerror: Missing Scheme in request url h import scrapy class QuotesSpider(scrapy.Spider): name = "Mineracao" def start_requests(self):…
-
0
votes1
answer301
viewsHow to pass Matlab to python?
f0 = 20000; a0 = 1; alfa = 0; T1 = f0/a0; sigma1 = T1*cos(deg2rad(alfa)); tau1 = T1*sin(deg2rad(alfa)); for teta=0:1:180 tau(teta+1) = (sigma1/2)*sin(deg2rad(2*teta)); sigma(teta+1) =…
-
0
votes1
answer213
viewsHow to make the elements of a tuple to be the arguments of a python function?
I will first remove the problem and then explain what I am trying to do. If you know how to answer the short problem, you don’t need to see the rest. Is there a way to pass the elements of a tuple…
-
0
votes1
answer185
viewsHow to use Python integrated with . CSV
Good morning. I have to read a field(line) from a file in . csv and fill in a certain field on the system. How should I do? Example, man . csv is the mass of data for filling in a register.
-
0
votes2
answers495
viewsType of list elements - Python
I have two lists of different sizes. The first is a list of lists. Where I need to compare the type of elements of this first list list with another list containing data type (str, int, float,..).…
-
0
votes1
answer46
viewsTelnetlib does not properly close the socket
I’m developing a python script that sends text using a telnet link to a portech mv-372. The script works correctly but after some time the telnet connection drops and throws an exception "[Errno 32]…
-
0
votes0
answers42
viewsProblems when generating executable
I’ve never seen myself in need of generating a file. EXE, because my programs were tested on my own machine, but now however I need to generate an EXE to test on other computers. In my program I…
-
0
votes0
answers1024
viewsPygame - mixer.music()
I’m set up a system that uses Pygame tools, in other terms, I’m creating an application that runs songs, I’ve been trying to make that, with the current music ending (stored in one vector), the…
-
0
votes1
answer4239
viewsHow to remove special character and string column point from a data frame?
raw_data = {'NAME': ['José L. da Silva', 'Ricardo Proença', 'Antônio de Morais']} df = pd.DataFrame(raw_data, columns = ['NAME']) How to transform the names of the NAME column into: Jose L da Silva…
-
0
votes1
answer1686
viewsPython/Pandas - How to remove extra space between two words from a data frame column
The "strip" function removes the spaces on the left and right, but does not remove the spaces between the words: raw_data = {'NAME': [' José Luiz da Silva ']} df = pd.DataFrame(raw_data, columns =…