Open main menu

CDOT Wiki β

Changes

OPS435 Python Exercise 1

779 bytes added, 07:33, 22 June 2018
selected items from a list to make useful data object
[[Category:rchan]]
= Objectives =
* read a single line from a text file
print(word_list) # <-- you should see the list of word when this line is executed
</pre>
Output from the above print() function:
<pre>
['rchan', 'pts/9', '10.40.91.236', 'Tue', 'Feb', '13', '16:53:42', '2018', '-', 'Tue', 'Feb', '13', '16:57:02', '2018', '(00:03)']
</pre>
= selected items from a list to make useful data object=
== login date and logout date ==
Login date in YYYYmmmdd format:
<pre>
login_date = word_list[7]+word_list[4]+word_list[5]
print('Login date:',login_date)
</pre>
The output will be:
<pre>
Login date: 2018Feb13
</pre>
 
Logout date in YYYYmmdd format:
<pre>
logout_date = word_list[13]+word_list[10]+word_list[11]
print('Logout date:, logout_date)
</pre>
The output will be:
<pre>
Logout date: 2018Feb13
</pre>
== login time and logout time ==
<pre>
login_time = word_list[6]
print('Login time:',login_time)
</pre>
The output will be:
<pre>
Login time:
</pre>
=manipulate data objects: date, time, user name, host IP=
1,760
edits