load module named "datetime" and change the directory of output file?

Y

ye juan

Hi, all

I have some questions to ask:

1. How can I add a standard module named "datetime" in
Jython when the error happens :"Traceback (innermost
last):
File "C:\python\test.py", line 3, in ?
ImportError: no module named datetime "
The line 3 is writen: "from datetime import datetime,
tzinfor"

2. I hope test.py outputs a file like test.txt, but I
want to change the directory of the result file named
test.txt. for example, the result is in
c:\python\test.txt, but I want to put it in
c:\python\result\test.txt. How can I change the
directory in java?

Thanks for your answer!

Sincerely,

Erica







___________________________________________________________
ÎÞÏÞÈÝÁ¿ÑÅ»¢Ïà²á£¬Ô­Í¼µÈ´óÏÂÔØ£¬³¬¿ìËٶȣ¬¸Ï¿ìÇÀ×¢£¡
http://cn.photos.yahoo.com
 
L

Lee Harr

1. How can I add a standard module named "datetime" in
Jython when the error happens :"Traceback (innermost
last):
File "C:\python\test.py", line 3, in ?
ImportError: no module named datetime "
The line 3 is writen: "from datetime import datetime,
tzinfor"

The datetime module was added with Python 2.3. I think
that Jython is still at the 2.1 or 2.2 level of Python.

I believe that the Jython team is pretty far along the
path to Python 2.4, but that is probably a question best
asked on one of their lists.


2. I hope test.py outputs a file like test.txt, but I
want to change the directory of the result file named
test.txt. for example, the result is in
c:\python\test.txt, but I want to put it in
c:\python\result\test.txt. How can I change the
directory in java?


Sort of depends on how you are writing the output.
You could do something like ...

fh = open(r"c:\python\result\test.txt", "w")
fh.write("something")

right?

What does your code look like now? It is easier to
help you fix it than to start fresh....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top