• Register
1 vote
33 views

Problem:

Hello all,

I’ve started learning python very recently. On the other day, I found a method called decode() 

I wrote a simple code using this method but unfortunately, it’s not working. What is the way to use the method decode()? 

Find my sample code attached below:

for lines in open('file','r'):
    decodedLine = lines.decode('dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=')
    line = decodedLine.split('\t')

 

12 7 7
15,250 points

1 Answer

0 votes

Solution:

Let me show you the basic usages of decode() and encode().

Str = "Hello World!";
Str = Str.encode('base64','strict');

print "Encoded String: " + Str
print "Decoded String: " + Str.decode('base64','strict')

I wrote a program that encodes our program and decodes it later on. And my program is producing the output:

Encoded String: SGVsbG8gV29ybGQh

Decoded String: Hello World!

 

For more information, please check this documentation

13 9 6
94,240 points

Related questions

0 votes
1 answer 193 views
193 views
Problem: I am working on the sort function but while doing a small problem I am getting a error can you please what I am doing wrong,Program that takes a list of student name and sorts them to create a class roll number. The list of names will be given on line separated by ... item.sort(lambda x, y: cmp(x.lower(),y.lower())) print(item) AttributeError: 'str' object has no attribute 'sort'" Error"
asked Jun 9 Gavin 15.3k points
1 vote
1 answer 333 views
333 views
Problem: I am newbee in python program and I wrote this code: def DeletChar(e, b) : counts = e.count(b) while counts : e.remove(b) counts -= 1 print(e) if __name__ == '__main__' : e = "LOVENOTLOLOVE" DeletChar(e,'L') But this code gives me the following ... main.py", line 9, in DeletChar e.remove(b) AttributeError: 'str' object has no attribute 'remove' Can anyone help me out to fix this problem?
asked Apr 8 LizzyM 6.1k points
0 votes
0 answers 3 views
3 views
This line: sift = cv2.xfeatures2d.SIFT_create() return error: Traceback (most recent call last): File "C:/Python27/openCVskrypty/GUI/SOLUTION2.py", line 11, in <module> sift = cv2.xfeatures2d.SIFT_create() AttributeError: 'module' object has no attribute 'xfeatures2d' I ... ) and I haven't got xfeatures2d module. Does anyone know why? Can I download it separately? Thanks for help how fix this.
asked 15 hours ago psandprop 800 points
0 votes
0 answers 7 views
7 views
Using Python Regex to retrieve certain content from a search box on a webpage with selenium.webDriver searchbox = driver.find_element_by_class_name("searchbox") searchbox_result = re.match(r"^.*(?=(\())", searchbox).group() The code works as long as the search box ... is error: AttributeError: 'NoneType' object has no attribute 'group' How can I make the script handle the "No results" situation?
asked 1 day ago psandprop 800 points