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
-
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
votes1
answer559
viewsError installing Python applications on Ubuntu 17.04
I want to put Jango, I’ve done all the process and everything, but when I do Pip install Django or other things related to python, always give this error. marcos@MarcosViana:~$ sudo apt-get -f…
-
2
votes1
answer42
viewsSeek word with accuracy
Good staff I have a small text of 1859 words where I have stored it all in a variable string format. The question and the next I have this little code I made below: w = wordstring.split() i = 0 for…
python-3.xasked 7 years, 2 months ago GlaucioFonseca 317 -
2
votes2
answers61
viewsdefault values for namedtuple
When creating a class I can set some default values: class Point: def __init__(self, x, y, z=0): self.x = x self.y = y self.z = z How to proceed the same way for namedtuple? from collection import…
-
2
votes0
answers785
viewsPython Pandas CSV
I started to learn Python not long ago and I’m doing a project to normalize customer data. But I don’t know how to make a comparison like: read on CSV field CP7, search for all CP7 of CSV CTT and…
-
2
votes2
answers12373
views"perfect" square root in python and identify the rest:
It is for python 3: What I’m looking to do is show the rest of a square-root account that only accepts as many integers as possible as an answer. For example: import math x=math.sqrt(87) print(x)…
-
2
votes2
answers8846
viewsSyntaxerror: unindent does not match any Outer indentation level
What should I do when this error message appears: "Syntaxerror: unindent does not match any Outer indentation level"? I cannot declare the Else of the variable. Follow a print of the problem and the…
-
2
votes1
answer106
viewsPython Wordlist generation problem (2.7)
I’m trying to write a python script that takes n keywords and a number as input. This number will be my maximum range of string that will be written to the Wordlist. 1° Problem: As many combinations…
-
2
votes1
answer523
viewspython error when importing fields with accentuated text
I have an error when running the command below, generates the text file correctly when importing texts from the database without accentuation, but when there is some accentuation appears the error:…
-
2
votes1
answer1958
viewsAssociate two lists in python
Associate two lists, a car name list and another color list and each containing n elements: listaCarros = ["gol","uno","corsa","palio","idea"] listaCores = ["branco","verde","preto","cinza","azul"]…
-
2
votes2
answers81
viewsFix incorrect module return
Mathematically speaking why it happens and how to fix the following "error" in python: >>>10.53 % 1 0.5299999999999994 I’d like to understand how the python works to obtain this value, why…
-
2
votes1
answer612
viewsPass PHP variable to Python longer than 14 characters
Problem passing Python variable to PHP over 14 characters PHP code $p = 123456789101112 $pyscript = 'C:\\Users\\python\\teste.py'; $python = 'C:\\Python34\\python.exe'; $run = shell_exec("$python…
-
2
votes1
answer1010
viewsUse from module import* vs use import module in python 3
The 2 do the same thing (I think at least), but have always told me that import module is better then I always used this method, but the method from module import * makes the code more concise since…
-
2
votes1
answer519
viewsProblem to install Scipy
People I’m having trouble installing the scipy for pycharm and by Pip, I am taking the following considerations when installing the SciPy 1 - Is compatible with python 3.6 2 - On Pip type the…
-
2
votes1
answer192
viewsHow to suspend a command without disturbing active commands
well I wanted to know if you know a command in python that suspends the operation of a command (for a few seconds)without disturbing the other commands that are active, because it was wanting to…
-
2
votes1
answer334
viewsError in html Django?
Good morning guys, I’m having a little problem referencing my variable in the html of Django. I’m a beginner in the web part, I’m trying to create a site for a project, so during the html…
-
2
votes1
answer2323
viewsMounting table from a csv, grouped by week, with python and pandas
I am using pandas and open the following table using the code tst = pd.read_csv('Iteracao.csv',delimiter=",") I’m trying to group as follows, where week 1 is the week of the date…
-
2
votes1
answer3717
viewsWays to find out which is the largest and smallest number typed in the user input in a for
Well briefly I have a doubt whether there is a way to make this code otherwise more "simple". The code itself is already simple but wanted to know if there is another way using fewer lines or…
-
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
votes2
answers597
viewsHow to put more than one parameter in Python?
Guys I’m learning Python3 and I’m having trouble making an implementation in Python. For example, in C: for (fatorial = numero; fatorial >= 1; fatorial--) I want to put this implementation up in…
-
2
votes1
answer410
viewsStoring values of variables within the while function
In an exercise I answered with this code: qntd_alunos = int(input("Digite a quantidade de alunos: ")) qnt = 0 while qnt <= qntd_alunos-1: MB1 = float(input("Digite a média do primeiro bimestre:…
-
2
votes1
answer187
viewsHow could I make an app that works in the background with python and kivy?
I’m trying to make a kivy app that takes information from a database in the background, and when a change occurs in the database, send a notification to the user. Someone would know to tell me if…
-
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
votes2
answers1647
viewsUse of def function
I would like to create a function def to the first input and then return it in the third line. Example: def se(): sex = input('Digite seu sexo:') while sex != 'M' and sex != 'F': #não sei como se…
-
2
votes1
answer525
viewsMethod of choice with while
I have two options and the program should say which one was chosen, if the input is wrong should ask to repeat the request. Problems: Option 2 repeats 2 times until right. Option 1 does not say a…
-
2
votes2
answers991
viewsHow to read numbers separated by hyphens in a text file?
Let’s say I have a text file where its configuration is: 1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20...-999 How do I read the file and go saving each number this is separated by -?…
-
2
votes2
answers26379
viewsReturning only the highest value of a Python list
I have the list ['4', '07', '08', '2017', '364', '355673087875675'] and would like to re a formula to return the higher value, which in this case would be the '355673087875675', tried to use the…
-
2
votes1
answer637
viewsCan you make an auto-executable script in Python? (Autorun)
Hello, I’m starting to learn Python, I know only the basics, I wanted to make a script self executable (autorun), but I searched all over the internet and I couldn’t find anywhere to do an autorun…
-
2
votes2
answers233
viewsHow to extract all td names in order?
I need to extract all the names of people on this site: Camara.gov.br I wrote this code in Python3: from urllib.request import urlopen from bs4 import BeautifulSoup import urllib.request,…
-
2
votes2
answers7513
viewsHow can I use the results of one function within another in python
Good afternoon, I’m studying python alone and I’m trying to do a little programming with lists and functions, the program it will receive 10 names and store in a list, then 10 notes and store in…
-
2
votes0
answers160
viewsWrite and delete text in python terminal
I’m doing an experiment in Python 3.6.2 which is a terminal counter, but I want to display the count always in the same position. I tried to insert the string using the function print and then…
python-3.xasked 7 years ago Myke 41 -
2
votes1
answer76
viewsVariable creation
How do I create a variable and add the type as integer, but without having any value set? I need this variable to do this: a = int(input()) b = int(input()) x = int # tentei colocar o tipo da…
-
2
votes1
answer110
viewsError: "Selenium.common.exceptions.Webdriverexception: Message: Unknown error: Element is not clickable at point"
I’m setting a series of "checkboxes" in a variable lista. Then I run the variable through a loop so that only a few of them are clicked. But when the checkbox is not visible on the screen, Selenium…
-
2
votes2
answers4478
viewsList of objects in Python
I’m doing a function that returns an object list. Snippet from the code: def guarda_word(lista_palavras,lista_objeto,indice): for i in lista_palavras: if bool(lista_objeto) == True: # a list de…
-
2
votes2
answers5930
viewsList input
I have to receive input (10 integers) from the user and put them in a list but not allow repeated numbers to be entered. I tried but the program sees that the numbers are repeated does not insert…
-
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
answer376
viewsHow to make a "compilation" of the code in Python?
Knowing that Python is an interpreted language, is there any way to compile the program in Python? By this I mean, how to check syntax errors without having to wait for such part of the program to…
-
2
votes0
answers308
viewsAttributeerror: 'Nonetype' Object has no attribute 'startswith' when trying to install with Pip
I have a clean installation of Python on my machine and could not install any package using Pip. Python version D:\Users\julio.campos>python --version Python 3.6.3 Version of the Pip…
-
2
votes2
answers778
viewsEmpty if declaration in function
It is possible to create a function that ends with an empty if statement and allows the code that called that function to determine if action? Example: def if(): if x>6: x = input("Valor de x")…
-
2
votes1
answer259
viewsCalculate occurrences in the overlapping string
would like to know how to make how many substring combinations is possible within a string, ex: string = 'abcdcdc' sub_string = 'cdc' the returned value I want in this case, is 2, because the code…
-
2
votes2
answers1583
viewsPython - Assign the value of an entry to a variable
I tried to use the command mensagem = str(entry.get()) but it doesn’t work, I tried to use the entry = Entry(root, textvariable='mensagem') but also does not work, see the whole code basically want…
-
2
votes2
answers68
viewsIterator should return a String
Hello, I have the following code: import csv def carregar_acessos(): X = [] Y = [] arquivo = open('acesso_pagina.csv', 'rb') leitor = csv.reader(arquivo) next(leitor) for…
-
2
votes3
answers1051
viewsIdentify a numerical sequence in a text file
I’m new to Python, and I’m having a problem that I can’t find a solution to. I have a folder with about 10k of . txt (written in many different ways). I need to extract the FIRST sequence of 17…
-
2
votes1
answer3009
viewsEquivalent of python Curl
I was learning to use API’s from websites to a project, and right at the beginning I had difficulties and had to ask. This was the example of the use of API to test credentials on the site, I…
-
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
votes1
answer333
viewsReplace function does not work for all cases
I made this script to read a TXT file, find a sequence of 20 digits in the text, and rename the file with the digit sequence found. I used the replace to remove all the characters that appear…
python-3.xasked 6 years, 11 months ago matt 21 -
2
votes1
answer120
viewsHow to avoid calling the same function several times?
I have two scripts files, one to access a CSV file, turn each row into a dictionary and return a list of dictionaries (lines). My second script is a function to create a new column in the file (C1),…
-
2
votes1
answer2238
viewsWrite file in JSON
I have a number of files in JSON format, to work better organize them all in a single file using the following method: import json filename = "dados_geral.json" for mensagens in range(1,6):…
-
2
votes1
answer59
viewsWhy is the class attribute not modified?
I only need to send a command from one process to the other, but I wanted to understand why when modifying the variable within a function, it does not appear in another function. from…
-
2
votes1
answer249
viewsHow to ignore certain elements in a list that will go through a random process? (pending)
This program finds 3x3 magic squares by brute force and prints automatically when it encounters a. code: import random vetor = [1, 2, 3, 4, 5, 6, 7, 8, 9] def magicsquare(): return…