Questions tagged as 'python'

2
answers

How to convert CSV to XLSX with python?

How do I convert a .csv file generated by python to .xlsx ? I have two problems: One of them is that I could not figure out how to do this conversion The second is that even if you pass the crawl <nome> -o <nom...
asked by 20.09.2018 / 06:35
1
answer

add number and exclude \ n in python

I have the txt file: NOME,n1,n2 JOAO,8,5 MARIA,5,6 PEDRO,0,9 I want to add the numbers, I did the following: arq=open('pergunta.txt','r') conteudo=arq.readlines() arq.close() for i in conteudo: a=i.split(',') b=a[1].replace('n1',...
asked by 25.10.2018 / 14:48
2
answers

Python uri online judge

Read an integer value X. Then display the 6 consecutive odd values from X, one value per line, even if X is the case. Entry: the entry will be a positive integer value. Output: The output will be a sequence of six odd numbers. x=int(inpu...
asked by 14.10.2018 / 15:53
2
answers

Check if directory 'B' is inside directory 'A'

I'm developing a script that checks the last access date of each file within every tree of a chosen directory. Files with more than X days without access will be moved to another directory. As a precaution, I need to be detected if the destinati...
asked by 20.10.2018 / 17:12
1
answer

Force the implementation of certain type of abstract method

In Python it is possible to define classes abstratas and métodos abstratos in a slightly simple way, for example: class Spam(ABC): @abstractmethod def grok(self): pass This class can not be instantiated...
asked by 22.10.2018 / 03:36
1
answer

Replace words in a text that are formed, necessarily, formed of letters and numbers

I am trying to replace words in a text that are formed, necessarily, formed of letters and numbers. I've tried this: def passwords(): df['C'] = df['C'].str.replace(r'[a-zA-Z0-9]', '<password>') return df My data:...
asked by 06.12.2018 / 11:54
1
answer

Difference between algorithms that read numbers until you receive the number 999

What's the difference between these codes? First code: cont = 0 n = 0 total = 0 n = int(input("Digite 999 para parar")) while n != 999: n = int(input("Digite 999 para parar")) cont += 1 total += n print(total) Second code:...
asked by 14.12.2018 / 20:00
1
answer

UTF8 invalid codec in python [closed]

I'm using this code in the script: #! /usr/bin/env python # coding: utf8 import MySQLdb db = MySQLdb.connect(host="xxx.xxx.x.xx", user="xxxxx", passwd="xxxxxxx", db="xxxxxxx") cursor = db.cursor() cursor.execute("SELECT DataConsulta, Di...
asked by 12.12.2018 / 14:58
1
answer

Is this a Python 3.6 bug?

The following code is a demonstration of what I'm trying to do: I have a vector ( todos ) in which elements are added. The second vector ( alguns ) also receives new elements, and we need to know if elements of alguns are alre...
asked by 15.11.2018 / 13:52
1
answer

calculate area and print it in another txt file in python

I have an area.txt file: quadrado;2 retangulo;2;3 I want to create another txt file so it looks like this: quadrado;2;4 retangulo;2;3;6 I did it the following way but it's wrong: arq=open('area.txt','r') conteudo=arq.readlines() arq....
asked by 18.11.2018 / 21:03