Python Exercise Example 98
**Problem:** Input a string from the keyboard, convert all lowercase letters to uppercase, then output and save it to a disk file "test".
**Analysis:** None.
Program source code:
Example
#!/usr/bin/python
-- coding: UTF-8 --
if
name
==
'
main
'
:
fp
=
open
(
'
test.txt
'
,
'
w
'
)
string
=
raw_input
(
'
please input a string:
\n
'
)
string
=
string
.
upper
(
)
fp
.
write
(
string
)
fp
=
open
(
'
test.txt
'
,
'
r
'
)
fp
.
read
(
)
fp
.
close
(
)
The output of the above example is:
please input a string:
runoob.com
RUNOOB.COM
Python 100 Examples