Skip to content Skip to sidebar Skip to footer

Python Script Run Through IDLE Has No Output

I’m using the Windows version of Python 2.7 with IDLE. If I run the following code import os os.getcwd() through IDLE (Run module F5), I get no output in the Python shell. If I

Solution 1:

When you call a function, that function may return a value, and in this case os.getcwd() returns a string. Here, you never do anything to that string, so nothing happens - there's no output because you never print the string.

For example,

print os.getcwd()

would output what you would expect.

Reading your comment above, most Python interpreters will print out a representation of the return value of your code after it has been interpreted. This is why you see the string "printed" in the Python shell. However, when actually running the code, return values do not output.


Post a Comment for "Python Script Run Through IDLE Has No Output"