如何在sys.path中添加新路径?

编程入门 行业动态 更新时间:2024-10-28 07:34:10
本文介绍了如何在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>在消息中写道 news:11 ********************** @ o13g2000cwo.googlegr oups ...

你可以这样做: 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 sysprint 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> wrote in message news:11**********************@o13g2000cwo.googlegr oups...

You can do it this way: sys.path.append("C:\Temp") Alejandro

更多推荐

如何在sys.path中添加新路径?

本文发布于:2023-05-31 10:09:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389614.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   如何在   sys   path

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!