Running script in Python command line

61 views Asked by At

I am quite new to Python. I have python27 installed in my PC(windows). I am trying to run a script in python command line. My script was named "Script". And that contains

import sys # Load a library module
print(sys.platform)
print(2 ** 100) # Raise 2 to a power
x = 'Spam!'
print(x * 8) # String repetition

and when i import the script with writing import Script, it gives this

win32
1267650600228229401496703205376
Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named py

why the error message appears here? TIA. :)

1

There are 1 answers

2
varnit On

instead of writing import myscript.py simply use

import myscript

note that myscript.py should be in the same location