Posts by stack.cardoso • 417 points
62 posts
-
-2
votes2
answers60
viewsA: Encrypt a python string
Depends on symmetric or asymmetric encryption. There are libraries that help create good encryption using AES and RSA. a simple example using the xor function: The bigger the safer the key, the…
-
-1
votes2
answers81
viewsA: Check which numbers are primes within a vector
Hello, I hope you understand my explanation if we don’t have a dialogue :p explanation of the loop: After entering the values (vector size), you have to expand the number , the range function will…
-
0
votes2
answers56
viewsA: Count how many times a certain value appears in a list
In your case the input returns a literal type, its list contains literals ['12','32'] need to convert for [12,32] without single quotation marks. Foi Transposta a lista e convertida em numero…
-
0
votes1
answer7
viewsA: Show text on page from Django database
def __str__(self): return f'{name} {phone} {obs} {status}' __str__ is a function used to return a string representation of an object in the class indications ( Class name always uppercase to…
-
0
votes1
answer21
viewsA: Django - How to interact 2
Subscribe the get and post methods either the View or Createview as well as using get_queryset and get_success_url, If there is a Foreignkey, you have to pass it to another form directly. class…
-
0
votes2
answers878
viewsA: Get data from Django view
At the model instance the return of the email can be specified by def __str__(self): return self.email If there’s a warning like: str_ returned non-string Fix the return that is not a string. def…
-
0
votes2
answers589
viewsA: Legacy of templates with Django
Start with Settings.py, if properly specified DEBUG and templates and with regard to the archives static DEBUG = True # em desenvolvimento INSTALLED_APPS = [ 'suaAplicação', ] TEMPLATES = [ {…
-
0
votes2
answers311
viewsA: Deploy Python project to Heroku with error
I would indicate using an api for postgresql dj-database-url and configure the email server in the same directly in the Settings. For me never gave problems! import dj_database_url DATABASES = {…
-
0
votes2
answers53
viewsA: How to keep the window open in Python Kivy?
from kivy.app import App from kivy.uix.label import Label def build(): # retornar o gratico 3 return Label(text="Label") # ao iniciada retornara a classe de label janela = App() # instancia de App 1…
-
2
votes2
answers58
viewsA: Recover database data on Django
To retrieve database values for an html or directly in the console in views from .models import Dados #Do model dados dados = Dados.objects.all()# retorna todos os valores, mesmo são do tipo…
-
0
votes2
answers76
viewsA: Encrypt message through a python socket
Simply put, encrypt the message sends on the other side decrypts the message and encrypts the response. A: envia mensagem cifrada a B B: decrifa A -**crypt**--> B A <--**crypt**- B Client code…
-
0
votes1
answer30
viewsA: Django Oauth2 Facebook autentication
Authentication using social media requires an extra module in the project. The server did not find an intermediary to do this and due to missing return this warning. I state the…
-
0
votes2
answers949
viewsA: How can I use Pip in a python version installed by pyenv?
According to the comments this using gnu/linux, according to the FHS (Filesystem Hierarchy Standard) structure /usr/bin/ contains only non-essential files (which are not required for the system to…
-
0
votes0
answers62
viewsQ: List users contained in the Django group
I followed the explanations of a page to create a group and add users to the group. But now I want to list the users contained in the group and show in html html tried some variations but no return…
-
0
votes0
answers24
viewsQ: Authentication Django login returns 405 after logging in
The login page after being filled should redirect to the page that requires authentication but returns in the console "POST /login/ HTTP/1.1" 405 0 and in the browser returns to blank login page.…
-
1
votes1
answer55
viewsA: How to assign a function to a kivy button?
def printar(self): print("ação") Button: id: option text: "Options" on_press: root.printar() Whenever there is an action on the button the function called printar() will be started, if only call the…
-
2
votes4
answers350
viewsA: How to add values from a dictionary with arrays by the Python key?
Basics of a dictionary to run it: 'get', 'items', 'keys' 'values' interacting by keys: for i in a.keys(): print(i) interacting by the values contained in the key: for i in a.values(): print(i)…
-
0
votes1
answer65
viewsQ: Classification of grammar in nltk
I am using the lib Natural Language Tool Kit to treat some texts and in this lib has the feature Rslpstemmer() removes almost the whole word and leaves the radical. But the words Perfect homonyms…
-
0
votes1
answer68
viewsA: Inserting records into the database from a file
updated the reply: Urls: from django.urls import path from .views import CarregarView #, carrega , urlpatterns = [ # path('carregar1/', carrega), path('carregar2/', CarregarView.as_view()) ] Forms:…
-
0
votes2
answers33
viewsA: Problems making the POST in Django
Try with Class based views: form: from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User class CadastroForm(UserCreationForm): class Meta: model = User…
-
0
votes2
answers58
viewsA: I cannot execute if and Elif commands
The input() function accepts a string as input, a literal. When in the variable reg the assignment to function, it will compare a string. no if , is comparing a literal to an integer. Could use this…
-
0
votes2
answers376
viewsA: Django does not connect to mysql database
py Settings. There’s not so much mystery, Pip install Pymysql DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql',# nome do driver 'NAME': 'nome_db', 'USER': 'usuario', 'PASSWORD':…
-
-1
votes1
answer33
viewsA: How do I call the email field from the default table auth_user?? needed to make users register with email, user and password
Using Function based views. Criação Formulario: app user, user manager #app usuario from django import forms from django.contrib.auth.models import User # utilizando autentificacao class…
-
0
votes3
answers37
viewsA: Send template data to database
Function based views def adiciona_professor(request): form = AdicionaProfessor(request.POST or None) #post ou None if str(request.method) == 'POST': # comparando com uma string if form.is_valid(): #…
-
2
votes2
answers1486
viewsA: How to remove square brackets and commas when printing a list in Python?
A function called Join that can be useful in this case takes a list of strings and returns a string. Within the function other functions are accepted: partition', 'replace', 'rfind', 'rindex',…
-
0
votes2
answers164
viewsA: Django does not create tables
If you previously made a makemigrations and then migrate it inside the folder that has the Client model to another folder called "Migrations" A pasta migrations: Deve estar com arquivos python…
-
0
votes2
answers50
viewsA: How to send text via the template via url in Django?
Dentro da views, verifique por usuario: Identificar se é anonimo: if str(request.user) != "AnonymousUser": print("usuario não registrado, anonimo") ...teu…
-
-1
votes2
answers80
viewsA: Why am I getting these errors: Typeerror: Object type <class 'str'> cannot be passed to C code
from Cryptodome.cifra import AES from Cryptodome.Util import Padding """ O tamanho da chave definida como 32, esta implementando 256 se o tamanho do vetor de…
pythonanswered stack.cardoso 417 -
0
votes2
answers668
viewsA: Problems in the automation of sending messages on Whatsapp through the Python Selenium library
I have already had in hand a project of this characteristic. I used the Whatsapp api to automate text and emoji submissions, uploading photos and videos was very loooongo the coding time but it…
-
0
votes2
answers93
viewsA: Python socket module - for loop - socket.gaierror: [Errno 11001] getaddrinfo failed
According to the documentation: socket exception.gaierror A subclass of Oserror, this exception is generated for errors related to addresses by getaddrinfo() and getnameinfo(). Oserror "file not…
socketanswered stack.cardoso 417 -
0
votes2
answers354
viewsA: Tensorflow - What is the best model to perform real-grade training?
For pattern recognition could utilize convolutional neural network (CNN) - Vggnet architecture based on some good neural network models, as the CAFFE model recognizes the standard :…
-
-1
votes3
answers66
viewsA: How to remove values that are in another list?
Just strengthening the understanding. You can consult the Python help utility if you need more guidance about this function just enter the interactive shell and type: help(set()) help ("something…
-
0
votes1
answer147
viewsA: Turn a list into a python pandas csv
Set the parameters in the writing that will format the way you want arquivo = open('novoarquivo.csv', 'w', newline='') #parametros de acordo com os caracteres de escape escrever= csv.writer(arquivo,…
-
0
votes2
answers158
viewsA: Django Staticfiles not found css does not load
In Settings.py try using these settings: First Step: DEBUG = True # caso estiver False o projeto esta em modo de produção ALLOWED_HOSTS = [] # caso esteja False adicione na lista ["*"] if those…
-
1
votes2
answers271
viewsA: Python script run every 1 second for 3 hours in a row
#https://pypi.org/project/APScheduler/ Pip install apscheduler Try scheduled (scheduled scheduling) from apscheduler.schedulers.background import BackgroundScheduler scheduler =…
python-3.xanswered stack.cardoso 417 -
2
votes2
answers109
viewsA: Iterating a string inside the for
The function "Len()" is a builtin of python it returns the string size ( straight to the subject comes internally in the language) >>> len("felipe") 6 To manipulate strings you can use the…
-
0
votes1
answer135
viewsA: Python - Inventory system
I do not know how to solve the proposed way however pygame has indicated control: for events in pygame.event.get():# sair if events.type == pygame.QUIT: print("faça algo") if events.type ==…
-
0
votes2
answers167
viewsA: Python library installation error by cmd
On the page pywhatkit on the side of a link with the name "Download files", click and the zipped file will be downloaded. Extract the file and enter the folder and enter the following statement:…
pythonanswered stack.cardoso 417 -
1
votes3
answers84
viewsA: Access values from a python json
import requests import json #Pode-se utilizar dicionario python para acessar conteudo no formato json #Acessar conteudo por chaves ou valores. #para acessar só indicar a…
-
0
votes1
answer47
viewsA: (Python file manipulation) I’m having trouble checking ip validation, how can I continue the code?
By simplifying this code: ip_validos=[] for ip in open("endereços.txt"): #condição...validar ips ip_validos = ip_validos + [ip.replace("\n",'')] print(ip.replace("\n",'')) #replace remove os espaço…
python-3.xanswered stack.cardoso 417 -
-1
votes3
answers164
viewsA: Read more than one line with input
lo :) First on your question "input only print first item" input from English to Portuguese = "Input When you need to enter some number for the program to do some procedure use that function,…
-
1
votes1
answer337
viewsA: python and excel(doing automation)
import openpyxl wb = openpyxl.Workbook() ob = wb.get_sheet_by_name('xXx') ob['c1'] = 'PYTHON' #<:--- ob['c1'].value cell coordinate can be used as key of dictionary in Worksheet object to write…
-
1
votes1
answer822
viewsA: How to click a button using Selenium in Python?
Hello! Essa tarefa pode ser feita em 3 formas diferentes: Usando :Id Usando : Nome da classe Usando : XPath from selenium import webdriver driver = webdriver.Chrome("driver...") driver.get('pagina')…
-
-1
votes3
answers500
viewsA: Python 3 Negative Indices
Indexes range from 0 to the amount of elements added. example: listaN1 = [1,2,3] """ três pontos (...) é uma Ellipsi , omissão de valor. """ #ou listaN2 = 'abc' #String em python tbm pode ser lista.…
python-3.xanswered stack.cardoso 417 -
0
votes1
answer325
viewsA: Module requests is imported into IDLE, but not into Thonny (the IDE I use)
Hello! In most IDE’s ( Integrated Development Environment ) has the option to choose which interpreter will be used, usually this setting is in the top bar of the ide. If the ide does not have this…
-
1
votes3
answers158
viewsA: Use of virtualenv python
Hello . About your question, yes you will have to turn on and off. But you can delegate this function to the operating system in use if you have only one environment however if you are using…
-
1
votes1
answer44
viewsA: ascending order:
def funcao(a,b,c): valor = [ ] # lista iniciada valor.append(a) # < -- valor adicionado valor.append(b) # < -- valor adicionado valor.append(c) # < -- valor…
pythonanswered stack.cardoso 417 -
0
votes3
answers740
viewsA: Problem with python library - Selenium
To use lib Selenium either in python or java require a web driver, firefox,Chrome or any browser has to download the driver corresponding to the desired browser. But if your PC browser is outdated,…
-
-1
votes1
answer43
viewsQ: One Layer Perceptron Neural Network, Inputs
Hello I’m having a doubt about going through the input and data weight without using the numpy. #AND entrada = [[0,0],[0,1],[1,0],[1,1]] peso = [0.0,0.0] The way I figure it is : inada1 x weight +…
-
0
votes1
answer39
viewsA: How to Install Python3 Idle together with Python 3.5.2 on Raspbian?
Now you would have 3 different versions of python. You could install an environment simulator, controlling which version to use. Try using. deb packages Here some https://ubuntu.pkgs.org/…
python-3.xanswered stack.cardoso 417