Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24607
| From | "梦幻草" <wustcsvstudio@vip.qq.com> |
|---|---|
| Subject | 转发:Re:how can I implement "cd" like shell in Python? |
| Date | 2012-06-28 19:39 +0800 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1598.1340883579.4697.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
thanks !But this method can not change the directory of the main process.For example: the current directory is "/home/work/local/scripts",this directory have a python script file "cd.py" after executing the script cd.py by "python cd.py ..",the current work directory has no changes,the path is still "/home/work/local/scripts" ------------------ Original ------------------ From: "Sergi Pasoev"; Date: 2012年6月28日(星期四) 晚上7:09 To: "python-list"; Subject: how can I implement "cd" like shell in Python? Do you mean to implement the cd command ? To what extent do you want to implement it ? if what you want is just to have a script to change the current working directory, it is as easy as this: import sys import os os.chdir(sys.argv[1]) plus you could add some error-handling code. -- http://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
转发:Re:how can I implement "cd" like shell in Python? "梦幻草" <wustcsvstudio@vip.qq.com> - 2012-06-28 19:39 +0800
csiph-web