- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Manogna has Published 40 Articles
Manogna
1K+ Views
LookupError Exception is the Base class for errors raised when something can’t be found. The base class for the exceptions that are raised when a key or index used on a mapping or sequence is invalid: IndexError, KeyError.An IndexError is raised when a sequence reference is out of range.The given ... Read More
Manogna
296 Views
EnvironmentError is the base class for errors that come from outside of Python (the operating system, filesystem, etc.). EnvironmentError Exception is a subclass of the StandarError class. It is the base class for IOError and OSError exceptions. It is not actually raised unlike its subclass errors like IOError and OSError.Any ... Read More
Manogna
524 Views
TypeErrors are caused by combining the wrong type of objects, or calling a function with the wrong type of object.Exampleimport sys try : ny = 'Statue of Liberty' my_list = [3, 4, 5, 8, 9] print my_list + ny except TypeError as e: print e print sys.exc_typeOutputcan only concatenate list ... Read More
Manogna
974 Views
A IndentationError occurs any time the parser finds source code that does not follow indentation rules. We can catch it when importing a module, since the module will be compiled on first import. You can't catch it in the same module that contains the try/except block, because with this exception, ... Read More
Manogna
5K+ Views
"Binary" files are any files where the format isn't made up of readable characters. Binary files can range from image files like JPEGs or GIFs, audio files like MP3s or binary document formats like Word or PDF. In Python, files are opened in text mode by default. To open files ... Read More
Manogna
2K+ Views
"Binary" files are any files where the format isn't made up of readable characters. Binary files can range from image files like GIFs, audio files like MP3s or binary document formats like Word or PDF. To open files in binary append mode, when specifying a mode, add 'ab' to it.For ... Read More
Manogna
187 Views
You can use the PDFMiner package to convert PDF to text.ExampleYou can use it in the following way: import sys from cStringIO import StringIO from pdfminer.pdfpage importPDFPage from pdfminer.pdfinterp importPDFResourceManager, PDFPageInterpreter from pdfminer.layout importLAParams from pdfminer.converter importXMLConverter, HTMLConverter, TextConverter def pdfparser(data): fp = file(data, 'rb') resource_manager = ... Read More
Manogna
220 Views
The function raw_input() presents a prompt to the user (the optional arg of raw_input([arg])), gets input from the user and returns the data input by the user in a string. For example, name = raw_input("What isyour name? ") print "Hello, %s." %nameThis differs from input() in that the latter tries ... Read More
Manogna
2K+ Views
To open files in read/write mode, specify 'w+' as the mode. For example, f = open('my_file.txt', 'w+') file_content = f.read() f.write('Hello World') f.close() Above code opens my_file.txt in write mode, stores the file content in file_content variable and rewrites the file to contain "Hello World". You can also use r+ mode ... Read More
Manogna
2K+ Views
To open binary files in binary read/write mode, specify 'w+b' as the mode(w=write, b=binary). For example, f = open('my_file.mp3', 'w+b') file_content = f.read() f.write(b'Hello') f.close()Above code opens my_file.mp3 in binary read/write mode, stores the file content in file_content variable and rewrites the file to contain "Hello" in binary. You can ... Read More