如何在Python中获取当前文件目录的完整路径?(How to get full path of current file's directory in Python?)
我想获取当前文件的目录路径。
我试过了:>>> os.path.abspath(__file__) 'C:\\python27\\test.py'
但是如何检索目录的路径? 例如:
'C:\\python27\\'
I want to get the current file's directory path.
I tried:>>> os.path.abspath(__file__) 'C:\\python27\\test.py'
But how can I retrieve the directory's path? For example:
'C:\\python27\\'
原文:https://stackoverflow.com/questions/3430372
更新时间:2023-12-21 22:12
最满意答案
感谢您的快速回复,但我找到了另一种解决方案。
我在Div中添加了更新面板和runat参数。
<asp:UpdatePanel ID="upErrorDiv" runat="server"><ContentTemplate> <div runat="server" id="ErrorDiv2" title="Error" style="visibility:hidden"> <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Please select an option among the results and try again!</p> </div> </ContentTemplate></asp:UpdatePanel>
更改了后面的代码。
if (ProfileID == null) { ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivOpen", "document.getElementById('ErrorDiv2').style.visibility = 'visible';", true); ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivShow", "openModalDiv('ErrorDiv2');", true); return; }
Thanks for your quick reply but I found another solution.
I added both update panel and runat parameters to the Div.
<asp:UpdatePanel ID="upErrorDiv" runat="server"><ContentTemplate> <div runat="server" id="ErrorDiv2" title="Error" style="visibility:hidden"> <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Please select an option among the results and try again!</p> </div> </ContentTemplate></asp:UpdatePanel>
Changed the code behind as.
if (ProfileID == null) { ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivOpen", "document.getElementById('ErrorDiv2').style.visibility = 'visible';", true); ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivShow", "openModalDiv('ErrorDiv2');", true); return; }
相关问答
更多-
感谢您的快速回复,但我找到了另一种解决方案。 我在Div中添加了更新面板和runat参数。