Posts by Woss • 73,416 points
1,476 posts
-
2
votes1
answer386
viewsA: Open text file in float value list
You can read the file as CSV with the character delimiter \t: import csv def read_file(filename): with open(filename) as stream: reader = csv.reader(stream, delimiter='\t') for row in reader: yield…
-
4
votes2
answers224
viewsA: Take part of the CSS class name
You can even use the selector ^= of the CSS that will apply the style based on the prefix of the value in that attribute. For example, [class^="result_itens_"] will apply the style to all elements…
-
0
votes3
answers2203
viewsA: Change value of an Hidden input with jquery
The two Javascript functions that you did for me made no sense and I couldn’t even understand what their goal was, so I can’t analyze them. You say you should change the value of the field, but in…
-
3
votes2
answers81
viewsA: Problems in the use of PDO
In PHP you are sending the following header in the HTTP response: header("Content-type: application/json; charset=utf-8"); This will make jQuery understand that the answer is a JSON and will attempt…
-
2
votes1
answer326
viewsA: How to average values in a list using python?
I would recommend you to start thinking about organizing your solutions with functions, applying the principle of single liability. When you start creating a code that does everything sooner or…
-
0
votes1
answer39
viewsA: Using a Math function in Vue 2 framework
Your function is returning the result. Javascript will handle this internally and will not know that what you want is to update the value of this.numero. To do this, you need to specify that you…
-
2
votes1
answer401
viewsA: Return the last ID with PDO in PHP
The problem is in your call to lastInsertId. Are you calling the method in $this->obj, that defined as the return of prepare: $this->obj = $this->Conectar()->prepare($query); The return…
-
2
votes2
answers800
viewsA: How to perform two functions, both containing infinite loop, simultaneously in Python?
threading.Thread(target=cn.getStatusDetections()) Here you are calling the function cn.getStatusDetections and passing the return as target of thread. Since the function will never return, since it…
-
0
votes2
answers41
viewsA: When I try to display the values of a vector some more zeroes appear
Let’s assume I informed you that I desire 5 elements, so size_vector will be 5. On the line vector<int>values(size_vector) You define an integer vector of size 5 initialized with 0. That is,…
-
1
votes1
answer3022
viewsA: Find file using Python
As of Python version 3.4 there are no more justifications¹ to use the library os to manipulate directories and files, since in this version the library was added pathlib, that abstracts the…
-
1
votes1
answer61
viewsA: Error Javascript Code When Using Keyup Event
Assuming you have the value "luis ", when dividing into the blank, loweredText.split(" "), you will get the array ["luis", ""]. The undefined appears because within the loop you access the 0…
-
1
votes1
answer543
viewsA: Unsupported operand types
The variable $this->data is a array and the operator += will only work when the second operand is also a array. $data = [0]; $data += [1, 2, 3]; print_r($data); // [0, 1, 2, 3] Or array…
-
2
votes4
answers174
viewsA: Verify correct answer
First, I have to say that your HTML did not make much sense and seems to be poorly planned. You have a list that is not listed; you have 5 answer options for each question, but in fact you only have…
-
2
votes2
answers85
viewsA: How to use methods of an object within "with" in Python?
When you do something like: with Teste('Olá') as objeto_teste: objeto_teste.mostrar_var() The value of objeto_teste shall be defined from the return of the method __enter__. As your method has no…
-
1
votes1
answer244
viewsA: Storing input data in mysql + Javascript
One SQL works, the other doesn’t, so just check what’s different between them. The one that works is: "INSERT INTO users(nome, email) VALUES ('felipe', 'felipe@felipe')" That there are simple quotes…
-
2
votes2
answers1550
viewsA: Draw Inside a Python String
The main problem with the answer is that you used the methods lower and upper as if they were object modifiers. In Python a string is immutable and, by definition, cannot be modified. In this case,…
-
11
votes1
answer446
viewsQ: What is HTTP/3? Will it replace HTTP/2?
In the question What is the latest and stable version of HTTP? The existence of version 3 of the HTTP protocol has been cited. Is this new protocol specification intended to replace the HTTP/2…
-
2
votes1
answer49
viewsA: Make an application to read 6 values. Calculate and display
Your logic for calculating the average is quite confusing and for me it made no sense to the point that I found the code was written almost randomly without being thought of before. So to understand…
-
0
votes1
answer30
viewsA: With pulling a variable out of the PHP function
Pass by parameter: function comentar($conn) { ... } And when you call the function, do comentar($conn). That’s why there are function parameters, manage scopes.…
-
5
votes3
answers177
viewsA: Why does the this(6) command inside a constructor initialize the class array?
Because the expression this(6) will invoke the constructor method that takes an integer as parameter, because it is the type of parameter you are passing. Luckily this method is set just below:…
-
3
votes1
answer206
viewsA: How to join multiple select Count(*) in mysql
Simply group the four columns and add to the desired function. SELECT status, categoria, mes, tier, COUNT(1) as total FROM tb_teste GROUP BY status, categoria, mes, tier This will return all…
-
5
votes1
answer45
viewsA: What is the purpose of using a name for Javascript class expressions?
The name given to a class expression is intended to allow auto-referencing while the expression is evaluated. That is, while Javascript evaluates the expression to define the value of var Nome, this…
-
3
votes1
answer281
viewsA: How to indent in JSON format
To display your JSON indented, simply use the third parameter of JSON.stringify, who receives a string which will be used for back-ups. const json = {"userId":1,"id":1,"title":"delectus aut…
-
1
votes1
answer31
viewsA: Positional path error in Python3
Apparently what you want is to define a function that reads from the user three values and returns them in the variables a, b and c. If you will read the user values it makes no sense to pass…
python-3.xanswered Woss 73,416 -
2
votes2
answers93
viewsA: Manipulating Python Lists with a mathematical formula
You have a sequence of values and want to generate another value from them. This is a 1:1 ratio, that is, for each input value you generate an output value. This process is called mapping and can be…
-
2
votes1
answer61
viewsA: Insert SQL with 3 arrays in the same table - PYTHON
Is not a loop infinity, but will really insert repeated because for each name on the list you go through all the quantities and for each quantity you go through all the products. Basically you will…
-
1
votes2
answers305
viewsA: Concatenate URL(Search)
You don’t need to update the value to each keystroke, you can do this only when the form is submitted. <form id="form-tipologia" action="http://teste.desenvol.br/#/pesquisa/esplanada/"…
-
2
votes2
answers328
viewsA: Assemble question and answer array
I have my doubts whether serializing the answers within the question record is the best solution. Even saving as JSON in this case would be much simpler since you only need to save structured data…
-
1
votes1
answer108
viewsA: JSON manipulation with PHP
In your case $empregados will be a array, then just access the second position of it, has no mysteries. $empregados = $jsonObj->empregados; $segundoEmpregado = $empregados[1]; echo…
-
1
votes2
answers741
viewsA: How do I put the value of a variable in a statement of another variable?
You can do this in multiple ways. 1) Concatenating the strings As you noticed can only concatenate the strings: PrecoProduto1 = float(input("Digite o preço do:" + NomeDoProduto1)) 2) Multiple calls…
-
3
votes1
answer60
viewsA: Change font with Javascript
Just add the value of rel of its element <link> and fix the CSS as it is using .body instead of body. const head = document.getElementsByTagName('head')[0]; const link =…
-
1
votes1
answer412
viewsA: How to run Dockerfile inside Docker-Compose.yml?
Docker Compose version 3 has the option build to inform a local Dockerfile to mount the container image. version: "3" services: myapp: build: . This will mount the image of the conatainer myapp from…
-
3
votes2
answers255
viewsA: How to make a horizontal line between two <td>?
Just add an element <span> with display: flex and define that the pseudo-element ::after as flex-grow: 1 to occupy all the remaining space. .with-line::after { display: inline-block; content:…
-
7
votes4
answers5082
viewsA: What does /= mean in Python?
This is one of what we call In-place Operators, which are operators executed jointly with the allocation operator on the object itself (hence the term in-place). In this case, the operator //= is…
-
0
votes2
answers44
viewsA: How to disable link via Javascript CONFIRM?
The natural action of a click on an element <a> is to forward the user to the URL indicated in the attribute href. Therefore, it is natural that the user clicking on the link is redirected to…
-
0
votes1
answer61
viewsQ: How does the declaration of a class in Python handle the external scope?
To illustrate, let’s consider this class statement: x = 1 class Foo: a = x b = [x] c = [x for _ in range(1)] print(f'x = {x}') # x = 1 print(f'Foo.a = {Foo.a}') # Foo.a = 1 print(f'Foo.b = {Foo.b}')…
-
1
votes2
answers309
viewsA: Get python Documents directory automatically
With the new directory manipulation API, pathlib, you can get the user directory from: from pathlib import Path home = Path.home() This will return an object referring to the directory home user in…
-
0
votes1
answer470
viewsA: File Upload Javascript + php
You can send the value of action: 'enviar' by the object itself FormData that you own, just do: var form_data = new FormData(); form_data.append('file', file_data); form_data.set('action',…
-
2
votes3
answers224
viewsA: Selection of the first number from a list
There are three conditions that the number needs to meet: It can’t be the first on the list, because there won’t be any negatives before it; Must be a positive number; The immediately preceding…
-
2
votes1
answer54
viewsA: Perform the reshape of different arrays
What you need is the transposed matrix, not a reshape. >>> matrix = numpy.matrix( ... [[1, 2, 3], ... [1, 2, 3], ... [1, 2, 3]] ... ) To get the transposed matrix just do matriz.T:…
-
5
votes2
answers75
viewsA: text superimposing the before
By default, the element before possesses display: inline, what will be displayed before the text, as expected, but without respecting the given dimensions. An element inline will always respect its…
-
1
votes2
answers170
viewsA: Error handling JSON data from a PHP API
You did: $json_obj = json_decode($response); If you use print_r($json_obj) or use any debug tool, you will see that the variable is: stdClass Object ( [rows] => Array ( [0] => stdClass Object…
-
3
votes2
answers33
viewsA: List array within exceptions (IF) and generate new status array
The operation you need to do is mapping. Convert an input value into an output value and as its name says, you can use the function array_map. Create a conversion function: function…
-
0
votes2
answers1146
viewsA: Save html form input in csv
Yes, just as you possibly did in Python you will need to have PHP process your request and save the information in the file. Possessing a array with the data you want to save in the CSV file you can…
-
8
votes2
answers110
viewsA: List Files by Extension - PHP
When analyzing the characters of your code we have: Result generated by https://www.soscisurvey.de/tools/view-chars.php All these characters marked in blue are "invisible" characters that appear to…
-
1
votes1
answer41
viewsA: Python Beautifulsoup doubt
The URL you are requesting returns a JSON. The Beatifulsoup library serves to parse XML (and, consequently, HTML) documents. That means you don’t have to use it. The Requests library itself already…
-
6
votes5
answers158
viewsA: Python - Function that copies content from one list to another list
I don’t see it as something useful for production, but supposing it’s just an exercise, let’s go. def copia_lista(dest, orig): ''' (list, list) -> None''' dest = orig.copy() When you do this…
-
3
votes1
answer94
viewsA: I cannot access the value of the array I receive from an API
The error message says that you cannot use an object of the type stdClass as a array. If you look at your exit, you’ll see that your array is an object stdClass, no other array: Array ( [0] =>…
-
1
votes1
answer372
views -
3
votes2
answers62
viewsA: Python 3: How to recover key names after a Sorted
You don’t need to create a list with just the values of value to sort them in ascending order and then get them again. You can always filter and sort keeping your original dictionary and sort them…