UNIT 3 Developing IoTs-Control Flow
UNIT 3 Developing IoTs-Control Flow
DEVELOPING IOTs
• Python allows reading and writing to files using the file object.
• The open(filename, mode) function is used to get a file
object.
• The mode can be read (r), write (w), append (a), read and
write (r+ or w+), read-binary (rb), write-binary (wb), etc.
• After the file contents have been read the close function is
called which closes the file object.
File Handling - Examples
Ex: To use seek function to set the position of the file pointer within
a file
Data.txt file: PrepBytes is an Ed-Tech Company
file=open(“data.txt”,’r’)
file.seek(10)
data=file.read(5)
print(data)
file.close() Output: is an
Python Packages of Interest for IoT
Python Packages of Interest for IoT
• JSON
• XML
• HTTPLib & URLLib
• SMTPLib
• NumPy
• Scikit-learn
Python Packages of Interest for IoT
JSON
• Java Script Object Notation (JSON) is an easy to read and write data-
interchange format.
• It is an alternative to XML and is easy for machines to parse and generate.
• It is built on two structures- a collection of name-value pairs (eg:-a Python
dictionary) and ordered lists of values (eg:- a Python List)
XML
• XML (Extensible Markup Language) is a data format for structured document
interchange.
• The Python minidom library(accessing and modifying XML documents)
provides a minimal implementation of the document object model interface
and has API similar to that in other languages.
Python Packages of Interest for IoT