Questions tagged as 'python'

1
answer

Get text within annotated tags using BeautifulSoup

I'm scraping an HTML document using BeautifulSoup4. But I was obliged to obtain Text commented. If I want to get commented text like this: <!-- este es el texto --> That can be obtained (bypassing the other statements) like this: te...
asked by 10.09.2018 / 11:21
2
answers

How to enter a date by keyboard and use it in Python?

I have a query, I did the exercise in C but I do not know how to pass it to Python, especially with the subject of when I enter the full date .. Here is the code in C #include <stdio.h> main(){ int DiaN, MesN, AnioN; int DiaH, MesH, An...
asked by 22.09.2018 / 02:51
1
answer

Problems copying data to csv file (to bytes-like object is required, not 'str')

I'm having trouble copying a column of data into a csv file. The original csv file looks something like this: ID;texto 1;El niño juega 2;La rana salta 3;Mi código no funciona The code I use reads data from a csv file, and generates a lis...
asked by 04.11.2017 / 19:30
2
answers

Delete occurrences in a text

I have to delete from "a las.. " to leave only the date, in Python. 21-MARZO-2017 A LAS 1600 HRS 31-ENERO A LAS 1300 HRS. 30-ENERO-2017 A LAS 1600 HRS. 20/02/2017 A LAS 1200 HORAS (MEDIODíA) 17-FEBRERO A LAS 1200 HRS (MEDIODíA) 18-NOVIE...
asked by 14.02.2017 / 17:35
2
answers

Problem with backpack problem

I am working with a case of a client in which he applies the algorithm Problem of the backpack . I am using the code that I attached, it works more or less and has errors. The example has 12 packages of different weights (which in their tota...
asked by 27.02.2016 / 04:44
1
answer

Is the result incorrect with Numpy in Python 3?

I was doing matrix exercises with numpy, but apparently it generated an error in the final answer: As we can see the final result of Z*Z is: [[9,4,1], [1,0,1], [1,4,9],] But after a suspicion I compared the results by hand w...
asked by 13.07.2016 / 06:13
4
answers

How to install pygame in Python3 with pip

How can I install pygame for python3 using pip ?. I have the version of Python 3.6.3. I tried with pip install pygame but it was installed in python 2.7. Thank you.     
asked by 27.12.2018 / 17:34
2
answers

How to throw exceptions using ternary operator in Python

I want to throw an exception on a single line to a method that a boolean has to receive if he does not receive it, by using a ternary operator. How can I do it? I tried to put a else pass but it does not validate the syntax def metodo...
asked by 11.08.2018 / 18:03
1
answer

Scope in Python

I follow a book about python but I found a doubt about the scope, I have the following code: pi = 3.14 def crear_area(pi = pi): def area(r): return pi*r*r return area area = crear_area(10) print(area(10)) #valor de ret...
asked by 13.03.2016 / 07:38
2
answers

How to generate a csv file from a list?

Hello, I have the following list l=[[1,2,3,4],[5,6,7,8]] and I want to generate a csv file something like this: 1 5 2 6 3 7 4 8 the code that I have worked on is this with open("output.csv", "wb") as f: writer = csv.writer(f) w...
asked by 02.06.2016 / 17:40