Questions tagged as 'python'

1
answer

Syntax error no print [closed]

code: # -*- coding: utf-8 -*- import MySQLdb db = MySQLdb.connect(host="xxx.xxx.x.xx", user="xxxxx", passwd="xxxxxxxx", db="xxxxxxx") cursor = db.cursor() cursor.execute("SELECT Dias, HoraConsulta, HoraSaida, nome, Consulta, centrodb.Local...
asked by 07.12.2018 / 10:00
1
answer

Download a torrent with python [closed]

How to download torrent files with Python in a simple way? Is there a python library that does this?     
asked by 18.10.2016 / 04:21
2
answers

I can not convert to integer [closed]

Make a function that reads a text file containing a list of IP addresses and generates two other files, one containing valid IP addresses and one containing the invalid addresses. The format of an IP address is num1.num.num.num , where...
asked by 20.06.2017 / 18:12
1
answer

Script that receives a list of integers, sorts and removes duplicates

I'm doing python course and I'm trying to solve the following exercise: Exercise 1 - Removing repeated elements Write the remove_repetitions function that receives a list of integers as a parameter, checks to see if such a list has repeat...
asked by 29.06.2018 / 19:32
1
answer

BeautifulSoup find method returns empty [closed]

I did a web scraping program in Python to check the price of Bitcoin on some exchanges , however the field I'm trying to download is left blank. In case, I'm trying to get the data is between the tags <div class="info"> and...
asked by 18.12.2017 / 15:14
1
answer

What's wrong? I use PyCharm

def par_ou_impar(result): divided = str(result).split('.') if len(divided) < 2: if divided[0] % 2 == 0: print('O resultado é par') else: print('O resultado é ímpar') if int(divided[1]) % 2 ==...
asked by 11.04.2018 / 18:37
2
answers

Save data to a csv file

I'm trying to save data to a csv file from fields: def inserir(): camp1 = str(ed1.get()) camp2 = str(ed2.get()) camp3 = str(ed3.get()) with open("contatos.csv","w") as _file: _file.write("Nome;tel;endereço")...
asked by 27.05.2018 / 16:16
1
answer

Use Mathematical tricks, can you speed up accounts in Python? [closed]

An example code about my doubt. %timeit lambda : 10000000000000000*10000000000000000 40.4 ns ± 0.592 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) %timeit lambda : "10000000000000000"+"10000000000000000"[1:] 40.6 ns ± 0.0841...
asked by 26.12.2018 / 17:14
1
answer

Number of "holes" in the letters of a text

I need to write a program in Python that counts the number of "holes" in a string. Imagine, for example, that the letters "A", "D", "O", "P", "R" have only one hole. Likewise, the letter "B" has two holes. The letters "C", "E", "F", "K" have no...
asked by 01.04.2016 / 13:12
1
answer

Python - I would like some examples of using "APLICATION / LD + JSON"

I've always worked with REST for integrations, now I'm using a new system where I can not just use pure JSON, they use LD Json, and I still do not quite understand this concept and I'm having some difficulties implementing it. So my question is...
asked by 07.05.2018 / 19:58