如何在sys.path中添加新路径? [英] how do i add a new path into sys.path?
问题描述
在我的系统上(win2k服务器,python 2.3.5),
import sys
print sys.path
[''C:\\'',''C:\\WINNT \\ system32 \\ python23.zip'',
''C:\\Python23 \\lib \\site-packages \\Pythonwin'',
''C:\\Python23 \\lib \\ site-packages \\win32'',
''C:\\Python23 \\\ \\ lib\\site-packages \\win32 \\lib'',
''C:\\Python23 \\lib \\\ package'',''C:\\Python23 \\DLLs'',
''C:\\Python23 \\lib'',''C: \\Python23 \\lib \\plat-win'',
''C:\\Python23 \\lib \\ li b-tk'',''C:\\Python23'',''D:\\Program Files \\DeLano
Scientific \\PYMOL \\\ \\ imodules'']
现在,我想添加C:\Python23 \Pmw \Pmw_1_2 \ lib"如何进入系统路径?
任何帮助都会受到赞赏。
我的亲切问候,
Wen
你可以这样做:
sys.path.append(" C :\ Temp")
Alejandro
wen写道:on我的系统(win2k服务器,python 2.3.5),
import sys
print sys.path
[''C:\\'',''C:\\WINNT \\ system32 \\python23.zip'',
''C:\\Python23 \\ \\\lib \\site-packages \\Pythonwin'',
''C:\\Python23 \\lib \\site-packages \\ win32' ',
''C:\\Python23 \\lib \\site-packages \\win32 \\lib'',
''C:\ \Python23\\ \lib \\site-packages'',''C:\\Python23 \\DLLs'',
''C:\\Python23 \\lib'' ,''C:\\Python23 \\lib \\plat-win'',
''C:\\Python23 \\lib \\lib-tk '',''C:\\Python23'',''D:\\Program Files \\DeLano
科学\\PYMOL \\modules'']
现在,我想添加C:\Python23 \Pmw \Pmw_1_2 \ lib"如何进入sys.path?
任何帮助都会受到赞赏。
提示1:Python列表附加一个( )和insert()方法
提示2:sys.path是一个列表
HTH
-
bruno desthuilliers
python -c" print''@''。join([''。''。join([w [:: - 1] for w in p .split(''。'')])
p in''o **** @ xiludom.gro''。split(''''')])"
如果我想添加路径C:\ temp进入sys.path,并使其可用于
任何其他新的python应用程序,比如我将C:\ temp添加到windows路径中,怎么样?
谢谢。
" apa" < AP ****** @ gmail.com>在消息中写道
news:11 ********************** @ o13g2000cwo.googlegr oups.com ...你可以这样做:
sys.path.append(" C:\ Temp")
亚历杭德罗>
on my system(win2k server, python 2.3.5),
import sys
print sys.path
[''C:\\'', ''C:\\WINNT\\system32\\python23.zip'',
''C:\\Python23\\lib\\site-packages\\Pythonwin'',
''C:\\Python23\\lib\\site-packages\\win32'',
''C:\\Python23\\lib\\site-packages\\win32\\lib'',
''C:\\Python23\\lib\\site-packages'', ''C:\\Python23\\DLLs'',
''C:\\Python23\\lib'', ''C:\\Python23\\lib\\plat-win'',
''C:\\Python23\\lib\\lib-tk'', ''C:\\Python23'', ''D:\\Program Files\\DeLano
Scientific\\PyMOL\\modules'']
now, i wanna add "C:\Python23\Pmw\Pmw_1_2\lib" into sys.path, how?
any help would be appreciated.
with my kind regards,
Wen
You can do it this way:
sys.path.append("C:\Temp")
Alejandro
wen wrote:on my system(win2k server, python 2.3.5),import sys
print sys.path
[''C:\\'', ''C:\\WINNT\\system32\\python23.zip'',
''C:\\Python23\\lib\\site-packages\\Pythonwin'',
''C:\\Python23\\lib\\site-packages\\win32'',
''C:\\Python23\\lib\\site-packages\\win32\\lib'',
''C:\\Python23\\lib\\site-packages'', ''C:\\Python23\\DLLs'',
''C:\\Python23\\lib'', ''C:\\Python23\\lib\\plat-win'',
''C:\\Python23\\lib\\lib-tk'', ''C:\\Python23'', ''D:\\Program Files\\DeLano
Scientific\\PyMOL\\modules'']
now, i wanna add "C:\Python23\Pmw\Pmw_1_2\lib" into sys.path, how?
any help would be appreciated.
hint 1: Python lists have an append() and an insert() method
hint 2: sys.path is a list
HTH
--
bruno desthuilliers
python -c "print ''@''.join([''.''.join([w[::-1] for w in p.split(''.'')]) for
p in ''o****@xiludom.gro''.split(''@'')])"
if i wanna add the path "C:\temp" into sys.path, and make it available for
any other new python apps, like i add C:\temp into windows path , how?
thank you.
"apa" <ap******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...You can do it this way:
sys.path.append("C:\Temp")
Alejandro
这篇关于如何在sys.path中添加新路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!