Posts by Vinicius Bussola • 664 points
37 posts
-
0
votes1
answer48
viewsA: Good evening I made a poll/poll code, but it’s not computing the vote when it’s said by name instead of number
Which python version of Windows are you using? Take a look at this link: The difference in input() and raw_input functions() If using Python 2, use raw_input instead of input. def pesquisa_audiencia…
-
0
votes1
answer44
viewsA: comp make that a variable of a database has the total of records that another bank owns?
Create this field as integer: totmatérias = models.IntegerField() When you want this table, Voce makes the logic and sends the number you want... You can override save method, so that when saving,…
-
0
votes1
answer135
viewsQ: Autocomplete taking data from a json of a url
I have this jquery <script> $(document).ready(function($){ $('[id="franchise"]').autocomplete({ source: "/ajax_calls/search/", minLength: 3, open: function(){ setTimeout(function () {…
-
1
votes3
answers354
viewsQ: How to hide sensitive information in Django?
In my Django project I have some sensitive variables, which I need to 'hide'. In general, save them in a file . env and read them with DADO_SENSIVEL = os.environ.get("DADO_SENSIVEL", default="")..…
-
1
votes1
answer103
viewsA: Form Django Loads Values but Not Saved
Because Voce doesn’t make your model Cadastral like this:? class RegulacaoPaciente(models.Model): cadastro_do_paciente = models.ForeignKey(CadastroDoPaciente, on_delete=models.CASCADE)…
-
0
votes1
answer103
viewsA: How to save updates to object via the Django form?
You are using a Modelform? # forms.py # ... class MyForm(forms.ModelForm): class Meta: model = MyModel # views.py # ... def atualizar(request, id): instance = get_object_or_404(MyModel, id=id) form…
-
0
votes1
answer336
viewsA: Python: Import command gets gray in Pycharm
In Pycharm, when the import is gray, it means it is not being used... If you use it anyway, for example: current_time = datetime.datetime.now() it will turn colorful. Pycharm offers some plugins to…
-
2
votes1
answer307
viewsA: Return in python 3
The Return closes the execution of the current function. Do some tests to see the behavior of Return.. For example: def test_return(var1, var2): print("Entrou") if var1 < var2: return "Menor"…
-
10
votes2
answers586
viewsQ: What does #noqa in Python mean?
Sometimes I find this comment in some Python code: #noqa. What does it mean? It’s specific to Python?
-
1
votes1
answer58
viewsA: I am trying to create a sketch of deleting items from a list. The data that will be deleted is the input() that will determine
Take a look at lists and the difference between pop, remove and del. Here, for example. In your case, as Voce wants to remove from the list by value selected, then you must use the remove... Follow…
-
0
votes1
answer59
viewsA: Plyer installation didn’t work, how to make it?
You came to look at the file setup py.? it has written that: For Android install additional dependency PyJNIus:: pip install https://github.com/kivy/pyjnius/zipball/master I don’t know if it solves…
-
1
votes2
answers149
viewsA: How to extract only words from any text, ignoring punctuation and uppercase letters?
Take a look at this link: # Open the file in read mode text = open("sample.txt", "r") # Create an empty dictionary d = dict() # Loop through each line of the file for line in text: # Remove the…
-
4
votes1
answer153
viewsA: What areas of mathematics should a game developer know?
I once played a game of "Tower Defense" with C++... It was a very cool and challenging experience.. You end up using "pure" math at specific points... In my case, I needed to use Pitagoras to make…
-
0
votes2
answers50
viewsA: Error in python3 function
Your code never enters elif y == 4: , for his while is <4 and not <=4... That way, he doesn’t create his dic4, therefore the error" local variable 'dic4' referenced before assignmen". Adjust…
-
0
votes1
answer112
viewsA: PYTHON - JSON format HTML table data
Do a search on webcrawler or Spider. Take a look at the beautifulsoup and Selenium…
-
1
votes4
answers568
viewsA: Write in a file numbers separated by a certain character
arquivo.write('teste') The code line above puts the string 'test' inside the archive. arquivo.write('teste' + ', ') The line above puts 'test, ' inside the file. (with comma and space at the end).…
pythonanswered Vinicius Bussola 664 -
-1
votes2
answers122
viewsA: I have a job in Python 3 and do not know how to proceed
Separate your problem into micro-problems, as @Woss commented. What you need to solve this problem? Create an empty list Request 20 times for the user to enter the numbers. What is the best way to…
-
1
votes1
answer52
viewsA: Remove duplicates in tuple stems
According to the first error, your code has this function sensas((a,b,c,a,b,c)), but did not find the variable to. Where is the creation of this variable? In errors 2 and 3, your code has this…
-
0
votes2
answers49
viewsA: Inserting information several times
vetorUm = ['este','é','um','vetor','para','exemplo','do','problema','apresentado','na','questão','acima'] vetorDois = ['vetor','problema','questão'] vetorResultado = [] for item1 in…
-
3
votes2
answers3924
viewsA: Change language on github
I found out what it was. First, as @Guilhermenascimento had already warned in some comment, my question is wrong as I discovered that inside my file Static there are yes 2 files. php. So yes, there…
-
2
votes2
answers3924
viewsQ: Change language on github
I have a project developed in Python with Django. I just created a repository and pulled on github and the project was set to PHP on the Github website: Some images of my project and its files: So:…
-
0
votes1
answer69
viewsA: Generate all possible letter exchanges in a word
In the code there are only the treatments for the letters (C and K), (M and N) and (J and G). There is no treatment for (I and Y) for example. You need to create it. Other details, you cannot trade…
-
0
votes1
answer273
viewsA: How to transform excel file into list? Python
Take a look at this link... Your code will look like the one below: import xlrd workbook = xlrd.open_workbook('teste.xls') #Use o nome do seu arquivo worksheet = workbook.sheet_by_name('Planilha1')…
-
0
votes2
answers157
viewsA: Send data via Arduino serial communication - Raspberry
You can handle that \n in your Raspberry code, with split() in the variable k, or try to use: k=comunicacaoSerial.readlines() instead of k=comunicacaoSerial.read()…
-
3
votes2
answers536
viewsA: Add values between ICT
In the above code, Voce always compares the values of the same Dict index.. And if you ever do anything like that?: ct_db = {u'AB-00': 18, u'RR-00': 14, u'LD-00': 56, u'SR-00': 33, u'YT-00': 452}…
-
1
votes2
answers241
viewsA: How to manipulate audio volume in real time
Take a look at this library: https://github.com/jiaaro/pydub #Make the beginning louder and the end quieter # boost volume by 6dB beginning = first_10_seconds + 6 # reduce volume by 3dB end =…
-
2
votes1
answer2565
viewsA: Check whether the number is positive, negative or zero
Pay attention: In this code of yours, there are these two pass, who are effectively doing nothing; The line fou.write('{};{}'.format(i,vazdiff())) is not inside a for, so save only 1 element in the…
pythonanswered Vinicius Bussola 664 -
1
votes2
answers65
viewsA: Syntax invalidates 2 degree equation
On the lines: X1=((-B)+(Delta**(1/2))/(2*A) X2=((-B)-(Delta**(1/2))/(2*A) We’re missing a parenthesis closure
-
0
votes2
answers473
viewsA: How to automatically populate a table field with a foreign key?
You can create a variable to pick up the object of the address you want. Then pass this object to the Insert in the Foreign key field. An example: endereco = Endereco.objetcts.get(id=1) #Faça a…
-
1
votes1
answer223
viewsA: Working with sheet dates
Take a look at that answer: https://stackoverflow.com/questions/13962837/reading-date-as-a-string-not-float-from-excel-using-python-xlrd In it, Voce finds this line of code that can help you:…
-
0
votes1
answer101
viewsA: Empty Dictionary Print - Webscrapping/python/xpath
Take a look at this code... See if you understand.. Any questions ask.. import requests from lxml import html def get_data(url_total): resp = requests.get(url=url_total, headers ={ 'User-Agent':…
-
0
votes2
answers52
viewsA: Python creating conditions or loop
You can create a while with the letter that will serve to exit the loop. In this case, I used the letter’s': print("Agora ira começar um joguinho. \n") print("Comece digitando nome do seu personagem…
-
0
votes1
answer188
viewsA: How can I impute values with Sublime text
You can run through the Sublime itself. Just save your project and hit "Ctrl"+"B" (or 'Tools', 'Build') to run the project. In Sublime, Voce can use the terminal itself (which is usually at the…
-
0
votes1
answer95
viewsQ: Django ORM to select with group by
I have a very simple model in Django: class TrackService(models.Model): ip = models.CharField(max_length=150, db_column='nm_grupo') creation_date =…
-
0
votes3
answers74
viewsA: Displaying message of no number read and accepting different types of input
First, put what you want to 'split' into the split() function: Change valores = input().split() for valores = input().split(',') Then make a if in case the input comes empty: if valores == ['']:…
-
0
votes1
answer345
viewsA: How to create Stored Procedures mysql with python from aqruivos . sql
I figured out what was causing the mistake. The answer is in this LINK. I changed my code to: DELIMITER $$ DROP PROCEDURE IF EXISTS sp_teste$$ CREATE DEFINER=`dbw`@`%` PROCEDURE sp_teste () BEGIN…
-
1
votes1
answer345
viewsQ: How to create Stored Procedures mysql with python from aqruivos . sql
I have some files .sql where I keep a procedure in each file. An example, procedure1.sql: DELIMITER $$ DROP PROCEDURE IF EXISTS sp_teste$$ CREATE DEFINER=`db`@`%` PROCEDURE sp_teste () BEGIN UPDATE…