Questions tagged as 'python'

1
answer

How do I send a file as an attachment by email without being automatically renamed?

I'm a beginner in sending emails through a script and I'm having a problem. Use Python 3.5. When sending attachments with the following script, they lose the extension and are renamed: def enviaremail(usuario,senha,mensagem,listadestinatarios)...
asked by 17.01.2017 / 20:36
1
answer

Why is a function calling itself?

def clinic(): print "Voce acabou de entrar na clinica!" print "Voce entra pela porta a esquerda (left) ou a direita (right)?" answer = raw_input("Digite left (esquerda) ou right (direita) e pressione 'Enter'.").lower() if answer =...
asked by 16.03.2017 / 01:05
2
answers

Identify whether the value being printed is of type float, string or int

In python it is possible to print various types of variables using print . Here's an example: print(3.4, "hello", 45); Or individually. print(3.4); print("hello"); print(45); How can you identify whether the value being printed i...
asked by 23.03.2017 / 17:00
3
answers

How to convert datetime / date to milliseconds in Python?

How to convert a type date and a datetime to milliseconds? >>> ontem # tipo date datetime.date(2015, 9, 29) >>> hoje # tipo datetime datetime.datetime(2015, 9, 30, 18, 15, 36, 856736)     
asked by 30.09.2015 / 23:28
3
answers

Is there any difference between calling "str (my_object)" and "my_object .__ str __ ()" in Python?

I noticed that in Python, when we have an object with the __str__ method, it is responsible for returning a string that represents the object - or something like that. Example: from uuid import uuid4 uuid4().__str__() The output i...
asked by 10.09.2015 / 18:12
3
answers

Is it possible to add int with str composed of text and numbers in Python?

I asked this question And in the case of python ? I can convert the string '1' str to 1 int . Example: 1 + int('1') # Imprime: 2 However, if I try to convert '1 cachorro' str to int ... int('1 c...
asked by 21.08.2015 / 18:46
1
answer

How to remove characters from a string?

The program should read two strings and remove from the first string all the letters that occur in the second string. Example: Let the strings be "chocolate" and "hollow", so the program should print "hlte". How to solve the problem using string...
asked by 28.03.2016 / 20:42
1
answer

Calculate the sum of the difference between 2 lists in Python

I need a function compara_listas(lista1, lista2) that receives two random lists and computes the sum of the difference between the elements of them. However, if any element of lista2 is greater than lista1 , it will become ne...
asked by 10.02.2017 / 00:49
2
answers

Function encode () and creation of hashes

I'm using Python 3.6 to do a program in which the person types an MD5 hash, so the program saves the hash in a variable, reads a txt file and plays the contents inside a list, where each name separated by , is an item in that list. Aft...
asked by 29.12.2018 / 01:15
2
answers

Identify string between two known strings in a string

I would like you to help me with the following: Given this CGC UUC GCU UUG GAA AAU UUG UGU GUU UUU UGU GGC UGC UCG CUG CUC AAA UUG UUC GCU GCU UUU UGU GUC CUG GCU GCU UUU AUU AUU UUA CGC UGC UUG GCG CUG CUY UUA CGC UGC UUG GGC UUG UUG UGG C...
asked by 31.10.2017 / 21:46