Questions tagged as 'python'

3
answers

How to transform content from a dictionary file into Python?

Well, I have a file and I'm getting the contents of it and adding it to a variable. The contents of the file and the value of the variable are like this: NAME=Maquina01 ID="MAQ 15478" version=08 I would like to take this content from the va...
asked by 11.12.2018 / 05:03
3
answers

Count number of elements in a python list

I have the following list: lista = [ 'A','B','C','D'] I want to count the number of elements to a certain point, I know that if you do len(lista) it will count all the elements but what I want is for example until C it will give me t...
asked by 06.12.2018 / 13:57
2
answers

Calculate how many NaN in each Python time

Good morning, I have a DF where you have NaN and I need to count how many NaN I have in each time. My df has a period of 31 days. I think I should use Groupby, but I'm not finding a way. import numpy as np import pandas as pd df...
asked by 17.03.2017 / 15:34
2
answers

Count number of times letters repeat in a text

Can you give me an idea how to write this algorithm in Python on less lines? (The algorithm counts the amount of a particular letter of the alphabet in a string.) #INSERINDO TEXTO string=input("Digite a string no qual quer ler quais letras do...
asked by 12.07.2018 / 22:27
2
answers

Get names from a list that have a size equal to 4

I am trying to solve the following problem: from a list of names, I need to return only names with len 4. I wrote the code below but apparently loop is not working since in a list with 4 names, two being within the criteria, it only...
asked by 13.07.2018 / 03:51
2
answers

How to create a directory in Python inside a server?

Using the mkdir function, you can create a file in any directory within your computer's folders: Import os diretorio = "C:\Users\CRIACAO 2\Desktop\teste" os.mkdir(diretorio) But when I try to create it inside the address of a server, the...
asked by 18.07.2018 / 22:13
2
answers

Function that determines if all the letters contained in a string are in the other

def isWordGuessed(secretWord, lettersGuessed): ''' secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: boolean, True if all the letters of secretWord are in letter...
asked by 22.04.2018 / 20:15
2
answers

Create the .txt file in PYTHON if it does not exist

The code: arquivo = open(input('Nome do arquivo a ser editado:'), 'r') texto = arquivo.readlines() texto.append(input('Insira o texto:')) arquivo = open(input('Nome do arquivo a ser editado:'), 'w') arqu...
asked by 06.06.2016 / 03:09
2
answers

Process NFe XML in Python

I have the following code that aims to fetch a particular node from an Electronic Invoice XML, but without success. I tested it with other XMLs and it worked. import xml.etree.ElementTree as ET tree = ET.parse("nfe.xml") doc = tree.getroot()...
asked by 01.06.2016 / 10:41
2
answers

How to remove specific position characters from a string?

I have a string read from a file that contains a data and the newline special character '\ n'. Example: dado = 'teste \n' First check the string size, so I can remove the last two characters, but how can I remove pointing to the character's...
asked by 29.01.2018 / 13:20