Most voted "python-2.7" questions
In the 2.x series of the Python programming language, version 2.7 is last and the latest. Use this tag only if the problem is specific to this version. Also use the [python] tag in your question.
Learn more…477 questions
Sort by count of
-
2
votes1
answer116
viewsDisplaying total connections to a certain IP address
I have a network dump (PCAP file) containing attacks slowloris. The following script will show the number of connections to IP 192.168.1.2 on port 80: /usr/sbin/tcpdump -anr myfile.pcap | sed…
-
2
votes0
answers56
views"No module named mayavi.mlab"
I’m trying to install Pylayer on Ubuntu Xenial, but when I try to export Coverage by from pylayers.antprop.coverage import * The following error appears: no module named mayavi.mlab But I have…
-
2
votes1
answer1140
viewsDifferentiate CPF and CNPJ that are in the same Mysql database column
Hello, I looked at several websites and couldn’t find them, so I decided to ask here. I have a relational database table, Mysql, which has a single column for both CPF and CNPJ. Also, this column is…
python-2.7asked 7 years, 9 months ago lfvv 121 -
2
votes1
answer115
viewsGraph of a Python denial of service attack
Friends, I generated the following chart: The code used was the following: import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y = []…
-
2
votes1
answer527
viewsRuntimeerror: maximum number of recursive calls exceeded - python
fibonacci_cache = {} def fibonacci(n): if n in fibonacci_cache: return fibonacci_cache[n] if n==1: value=1 elif n==2: value=1 elif n>2: value=fibonacci(n-1) + fibonacci(n-2)…
-
2
votes0
answers201
viewsCounting the number of connections per IP to a web server on port 80. Is regex correct?
I would like to count the number of connections per IP per second (at port 80) to a web server whose IP is 192.168.1.216. The input for the count is a network dump file in the PCAP (.pcap file)…
-
2
votes1
answer308
viewshow to remove CMD window after using.system in python
I have a Python 2.7 code that opens a PDF with os.system('meuarquivo.pdf') and it opens right. But when opening the file it also opens an empty CMD window. Is there any way I can close this window…
-
2
votes2
answers2868
viewsHow to know which libraries are being used in a python project?
I did an installation of an application made in Python, it works basically as follows, it installs Python, the program and at the end the installation copies the folder with the libraries for the…
-
2
votes2
answers409
viewsHow does Python keep the same memory reference as a list after resizing it?
We know the objects of the type list, because they are based on dynamic vectors, it has a maximum internal capacity. We also know that when this total capacity is reached and we want to insert a new…
-
2
votes1
answer278
viewsHow do I extract the name of multiple folders within a directory?
I need to get inside a folder called /users, where inside it the various folder and copy the name of all folders, follows the example. I wish I could take the name of these folders and save to a…
-
2
votes1
answer112
viewsImports within Python functions
I have seen cases where the developer does the import of a module within a function, some cases mainly in the Django documentation, why it is not very clear to me, if anyone can help me thank.…
-
2
votes1
answer5801
viewsHow to Create a communication between two clients via server using socket
import socket from threading import Thread def client(h, p): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # IPv4,tipo de socket s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) while…
-
2
votes0
answers165
viewsDisplay message(Qmessagebox) from a class other than the main one in Pyqt4
Friends, I ask for help from you, I imagine it is simple but I am having difficulty, because I am still learning object orientation with Pyqt4. I have a main class (Application) separate from the…
-
2
votes0
answers166
views(Socket) Client and Server Connection - how to get Cmd-> Client (Python) return
I want to execute a command in the client’s Cmd and return the values to the server. I Already Managed to Execute the command in the client’s Cmd... Now how do I return the values to the server? The…
-
2
votes1
answer2244
viewsConvert Python to exe
I have an app made in python that pulls several Imports, and my client does not want to install Python in his environment (because it is an Oracle server), the output I found was to create one . exe…
-
2
votes1
answer239
viewsPython processes
I’m studying the module multiprocessing and in all the examples in python documentation there is always a if verification in the examples, I know this checks whether the file is running directly or…
-
2
votes3
answers122
viewsIteration using "while"
I have a little trouble understanding while and I came across an exercise that asked me to do the following: Read N sequences and find out how many f has in each sequence. I cannot use for in that…
-
2
votes2
answers98
viewsHow to pass a Dict within a function, to be used in any case if necessary?
Good afternoon, I have a big keyError problem, because in my program that makes use of Dict will perform several processes, and if at some point he does not find an item in which he looks, will…
-
2
votes1
answer44
viewsModifying privileges with python
I am facing the following problem, I am increasing the privileges with "Elevated", but after running the.mkdir (), I would like him to lose his privileges and return to being an ordinary user.…
-
1
votes3
answers243
viewsRegex for hexadecimal colors
I have a small doubt: I have a regex that captures in 3 groups (2 values per group) of certain color, but this when I have 6 values(excluding the #), I would like to know how to implement to catch 1…
-
1
votes1
answer250
viewsHow to create separate objects from a loop?
class linha (): def __init__ (self, texto): self.texto = texto def criador (): for i in range(5): a = raw_input ('escreva: ') global objetoi objetoi = linha (a) How do I make the function criador…
-
1
votes1
answer174
viewsPython lib subprocess
Does anyone know why he opens the 2 terminals with the same command " ls-la " ? import subprocess cmd = ["xterm"] cmd.extend(['-e','bash','-c', 'ls -la; exec $SHELL']) subprocess.Popen(cmd,…
python-2.7asked 10 years, 3 months ago Pedro Souza 43 -
1
votes1
answer1069
viewsAutomatic filling of fields
I’m developing a applying with Django (1.6.2) and Python 2.7 for learning, the application performs registration, searches and edits in DB, in one of the registrations I perform I would like to…
-
1
votes1
answer2125
viewsTable editing, Datefield field
In one of the Insert’s of my application, I have a field Datefield, At first there is no error when saving the dates in the Database (Sqlite3), i inform a date in format DD/MM/AAAA, and she is saved…
-
1
votes1
answer492
viewsexec command does not work in python
Well, I’m not able to perform external functions (with exec) that will change global lists to be used in my main function, follows code: m = [] n = [] def mp((a,b),p): c = [n[0] for n in p] d =…
-
1
votes1
answer63
viewsIncrement URL via concatenation and using urllib2.urlop
I’m using the code below to access and do the scrapp of the emails that, at least as far as I have seen, are in three identical Urls that vary only the Numconsulta_cadastro=. By executing the code…
-
1
votes1
answer835
viewsError in reading JSON
I am trying to read the Jsons from a folder and get the proper values, I have tested all the Jsons to see if they were valid. The folder with the Jsons is called 'test' for dirname, dirnames,…
-
1
votes1
answer713
viewsError: IDLE crashes after closed
I have a lab with 35 machines running Windows 8.1 Pro. After installing Python (version 2.7.9 64bits) on all machines, I come across the following problems: Some machines install normally, but it is…
-
1
votes1
answer5597
viewsHow to remove a line from a text file
Hello. I am creating a program that opens, stores or deletes links. However, although I can remove the selected item from the link list I cannot delete the file line that corresponds to the selected…
-
1
votes2
answers158
viewsHow to use Kivy with Python 3.4.3 on Mac
How can I use Kivy with Python 3.4.3 on OS X? Only works with Python 2.7
-
1
votes1
answer74
viewsauth_token Node.js > Instagram
To make a script work I need the auth_token of an instagram app, and that according to instructions I should(and am) doing so:…
-
1
votes1
answer1095
viewsTransform query into dataframe [sqlalchemy + pandas]
I’m new to python and I want to create a function that will query the database[mysql] and convert it into a dataframe so that it can be sent by e-mail in format. csv. But I’m having problems in this…
-
1
votes1
answer48
viewsWorking on Python 2.7
How do I make an item bold? print ('Company Soon Young Viana') how do I insert an income tax spreadsheet? print ('PRODUCT'' t'u'UNIT PRICE'' t'QUANTITY'' t'u'TOTAL PRICE'' t''ICMS')
python-2.7asked 9 years, 5 months ago Sun 11 -
1
votes2
answers792
viewsSort list of lists
I have the following list of lists: lista = [['a', '1'], ['c', '3'], ['b', '2']] And I want to sort this list according to the numbers, which means I want it to stay that way: listaOrdenada =…
python-2.7asked 9 years, 5 months ago CSAnimor 731 -
1
votes1
answer3392
viewsAdding character to a string
Good person my doubt and the next, I have the following situation: i have the following variable >>> a = "EXAMPLE" Let’s assume I had to remove the letter "M" right string, in this case I…
-
1
votes1
answer23293
viewslist index out of range
Tsup=[] Te=0 dt=1 t=range(0,3600*2,dt) r=len(t) for i in range(0,r): Tsup.append(20) .... Tsup.append( (((Pj[i]+Ps-Pc[i]-Pr[i])*(dt))/((m_al*c_al[i])+(m_a*c_a[i])))+Tsup[i] ) if i==r:…
-
1
votes1
answer420
viewsProblem compiling python in pyqt libraries, with py2exe
I’m trying to compile with py2exe, but when I compile from error. Let me give you an example of this error, with Python 2.7 64-bit programs, pyqt4 for Python 2.7, and py2exe for Python 2.7. Follow…
-
1
votes1
answer234
viewsFile output accentuation problem saved on equipment
Good guys I have the following file saved in my equipment "names.txt", this one containing 1190 lines. Follow my python2.7 code: #/usr/bin/python env # -*- coding: UTF-8 -*- abrir =…
-
1
votes2
answers272
viewsItems of B whose indices are the positions of occurrences of equal elements in A
If I have the lists: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] B = [0.2, 0.3, 1.1, 0.2, 0.2, 0.7, 0.4, 0.6, 0.1, 0.3, 0.7, 0.4, 0.5, 0.5] How can I group in separate lists the…
-
1
votes1
answer1198
viewsRemove duplicates from a list keeping order
I had the list: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] , in making: ASemRepetidos=set(A) get ([10, 12, 15]), as it turns out, whether in A my first element is 12, in set(A)…
-
1
votes0
answers153
viewsSelecting and deleting random lines from csv in python
I need to make a small script in python that meets the following requirements: Open a csv file; Delete first row and first column from reading as it contains information that will not be needed in…
-
1
votes2
answers63
viewsLooping for as a looping parameter while
Whereas the list cont would have the values: cont = ['t','f','f','t','f'] It would be possible something like this: while(for cont in cont == 'f'): pass…
-
1
votes2
answers1216
viewsinput() and raw_input()
According to the Python 2.x documentation, it is recommended to use the function raw_input instead of input. Conversely, in the Python 3.x documentation, the function raw_input doesn’t even appear.…
-
1
votes1
answer2369
viewsRead excel information in matrix form with python
I’m using Python 2.7 to read values from an Excel document. When I have only one row of values with respective header I can read, doing from openpyxl import Workbook from openpyxl import…
-
1
votes1
answer1334
viewsHow to print a function in Python?
I’m trying to make this code work but I’m not getting it. Enter the name and year of birth, and return the correct values dps, but I can’t get back the number of years... What is my mistake? print…
-
1
votes0
answers68
viewshow do I develop a registration, listing and consultation system for vehicles and automakers? Obs:the listing is by name, by year, price range and by engine
def main(): titulo = '***** Veiculos.BD ***** \n ' menu = titulo + '1 - Novo Veiculo \n 2 - Listar veiculos'\ ' \n 3 - Remover \n 4 - editar \n 0 - Sair \n Opcao >> ' veiculos = [] while True:…
-
1
votes1
answer69
viewsProblem with urls and views inside the server
I was studying python and Django, and I decided to make my wedding website in January. The project runs perfectly on my local pc, the problem is when I deploy on digital Ocean and it gives that…
-
1
votes1
answer134
viewsPorting a Python 2 code to Python 3: Scan ICMP with errors
I have the following code: import random import socket import time import ipaddress import struct from threading import Thread def checksum(source_string): sum = 0 count_to = (len(source_string) /…
-
1
votes2
answers12804
viewsCounter in python
Well I’m doing a screenshot program but I want it to replace in the file name when saving, the characters "XX" by the print number. Ex: Screenshotxx.jpg in "XX" I want to put the print number ex:…
-
1
votes2
answers418
viewsBrowse 2D list in Python
I have the code below and I want to go through and display item by item from that list. However, I cannot do this because the entire list is displayed. I ask for your help. lista =…