From: David H. <Dav...@sa...> - 2006-02-01 15:44:23
|
1. If you go to the official documentation for the datetime module at: http://docs.python.org/lib/module-datetime.html It says "New in version 2.3.". Since Jython is still catching up to = Python 2.2, the datetime module is not available. 2. This is a basic Python programming question. I think there is a = python-tutor list at http://mail.python.org/mailman/listinfo/tutor that = is more appropriate for these questions. But I feel like teaching = someone today, so here's an answer. If you want a file to appear in a directory other than the current = directory, it is best to give the full path name to the file you want to = create. Try this (I called os.mkdir() to create the c:\python\result = directory, assuming it doesn't exist yet.) Jython 2.1 on java1.4.2_04 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import os >>> os.mkdir(r'c:\python\result') >>> f =3D open(r'c:\python\result\test.txt', 'w') >>> print >> f, "Hello, world" >>> f.close() >>> os.listdir(r'c:\python\result') ['test.txt'] >>> Also please research the os module and look at what the os.path.join() = function can do for you. -----Original Message----- From: jyt...@li... = [mailto:jyt...@li...] On Behalf Of ye juan Sent: Wednesday, February 01, 2006 10:02 AM To: jyt...@li... Subject: [Jython-users] load module named "datetime" and change the = directory of output file? Hi, all =20 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 =09 =09 =09 ___________________________________________________________ =D1=C5=BB=A21G=C3=E2=B7=D1=D3=CA=CF=E4=B0=D9=B7=D6=B0=D9=B7=C0=C0=AC=BB=F8= =D0=C5 http://cn.mail.yahoo.com/ ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log = files for problems? Stop! Download the new AJAX search engine that = makes searching your log files as easy as surfing the web. DOWNLOAD = SPLUNK! http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat=3D= 121642 _______________________________________________ Jython-users mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-users |