input and output the methods described in the preceding section can be used to perform raw / with the user for examplethe following code writes to standard output and reads line of input from standard inputimport sys sys stdout write("enter your name "name sys stdin readline(alternativelythe built-in function raw_input(promptcan read line of text from stdin and optionally print promptname raw_input("enter your name "lines read by raw_input(do not include the trailing newline this is different than reading directly from sys stdin where newlines are included in the input text in python raw_input(has been renamed to input(keyboard interrupts (typically generated by ctrl+cresult in keyboardinterrupt exception that can be caught using an exception handler if necessarythe values of sys stdoutsys stdinand sys stderr can be replaced with other file objectsin which case the print statement and input functions use the new values should it ever be necessary to restore the original value of sys stdoutit should be saved first the original values of sys stdoutsys stdinand sys stderr at interpreter startup are also available in sys _stdout_ _sys _stdin_ _and sys _stderr_ _respectively note that in some cases sys stdinsys stdoutand sys stderr may be altered by the use of an integrated development environment (idefor examplewhen python is run under idlesys stdin is replaced with an object that behaves like file but is really an object in the development environment in this casecertain lowlevel methodssuch as read(and seek()may be unavailable the print statement python uses special print statement to produce output on the file contained in sys stdout print accepts comma-separated list of objects such as the followingprint "the values are"xyz for each objectthe str(function is invoked to produce an output string these output strings are then joined and separated by single space to produce the final output string the output is terminated by newline unless trailing comma is supplied to the print statement in this casethe next print statement will insert space before printing more items the output of this space is controlled by the softspace attribute of the file being used for output print "the values are "xyzw print the same textusing two print statements print "the values are "xyomits trailing newline print zw space is printed before to produce formatted outputuse the string-formatting operator (%or the format(method as described in "operators and expressions here' an exampleprint "the values are % % % ( , ,zformatted / print "the values are { : { : { }format( , ,zf lib fl ff