Open main menu

CDOT Wiki β

Changes

OPS435 Python Exercise 1

108 bytes added, 21:08, 21 June 2018
Read a single line from a text file
line_in = f.readline()
print(line_in)
</pre>
 
Output of the above python code:
<pre>
manipulate data objects: date, time, user name, host IP
</pre>
= Split a single line into words and store all the words in a list =
Python code to split the line "line_in" into words:
<pre>
word_list = line_in.split() # <-- split the line into words using space
# store all the words as a list to word_list
1,760
edits