Info: OS: read and write

Read content of a directory:


import e32
import os

# drefine the directory to read
imagedir=u'c:\\nokia\images'

# read the directory
files=map(unicode,os.listdir(imagedir))

 

Example script : os_dir_read.py

 

 

Read an imgage into a variable:


import e32
import os

# read the directory
f=open('c:\\nokia\\images\\testimg.jpg'','rb')
test = f.read()
f.close()

 

Example script : os_dir_read.py (not there yet)

 

 

 

Write a file into a directory:

# drefine the directory and file name to write the file into
imagedir=u'c:\\witetest.txt'

# create the file
file = open(imagedir,'w')

# write some text into it
file.write('hello, this works')

# close the file
file.close()

Example script : os_dir_write.py

 



Write and read settings to/from the OS:

Write several variables with attached values as settings into a file on the OS, and also read the them.

Example script : read_write_settings_to_OS.py

Example script : read_write_settings_to_OS_descr.py

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Previous|Next  | Menu        Copyright (c) 2006 Jurgen Scheible