python unipath:当前文件目录(ancestor)的路径不输出(python unipath: path to current file directory (ancestor) outputs nothing)
我一直在努力学习python-unipath ,并且一直在掌握基本的命令。 然而,我一直被这个问题困扰。 所以,我想获得当前文件的祖先(2)。 所以,在Python解释器上,我做了这样的事情:
Python 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from unipath import Path >>> ORM_ROOT = Path("/home/foo/lump/foobar/turf/orm/unipath_try.py").ancestor(2) >>> ORM_ROOT Path('/home/foo/lump/foobar/turf')
..这是正确的,正是我想要的。 现在,我把它包装在一个文件中,如下所示:
# -*- coding: utf-8 -*- # unipath_try.py from unipath import Path ORM_ROOT = Path(__file__).ancestor(2) print ORM_ROOT
当我运行这个使用
python unipath_try.py
我得不到输出! 没有导入错误。 我完全困惑,为什么会这样 - 可能真的很愚蠢。 希望任何帮助/方向在这:(I have been trying to learn python-unipath and have been getting to grips with basic commands. However, I have been stumped by this issue. So, I would like to get the ancestor(2) of the current file. So, on the python interpretter, I do something like this:
Python 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from unipath import Path >>> ORM_ROOT = Path("/home/foo/lump/foobar/turf/orm/unipath_try.py").ancestor(2) >>> ORM_ROOT Path('/home/foo/lump/foobar/turf')
..which is correct and exactly what I want. Now, I wrap this in a file like so:
# -*- coding: utf-8 -*- # unipath_try.py from unipath import Path ORM_ROOT = Path(__file__).ancestor(2) print ORM_ROOT
when I run this using
python unipath_try.py
I get no output! No import errors either. I am completely baffled why this is - probably something really stupid. Would appreciate any help/direction on this :(
原文:https://stackoverflow.com/questions/18444093
最满意答案
没有技术上的理由说明为什么不使用
TWebBrowser
来显示地图或任何其他事情。 事实上,这是一个意见问题,很可能你听到了人们的意见,告诉你不要这样做。 不幸的是,堆栈溢出是一个问题/答案网站,所以像这样的问题不一定是可行的。
TWebBrowser
包装一个Internet Explorer浏览器窗口,并依赖于安装的任何版本的IE。 您可以在Internet Explorer中打开的任何内容也可以在包含Google地球的TWebBrowser
打开。 这是一个指向页面并加载它的问题。 至于技术上的原因,这里和那里可能会有一些小故障,但我不明白为什么。There is no technical reason why not to use the
TWebBrowser
to display maps, or anything for that matter. In fact, this is a matter of opinion, and most likely you have heard people's opinions telling you not to do so. Unfortunately, Stack Overflow is a Question/Answer site, so a question like this isn't necessarily feasible.The
TWebBrowser
wraps an Internet Explorer browser window, and relies on whatever version of IE is installed. Anything which you can open in Internet Explorer can also be opened in theTWebBrowser
, Google Earth included. It's a matter of pointing it to a page and loading it. As for technical reasons, there may be some glitches here and there, but I don't see why not.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
没有技术上的理由说明为什么不使用TWebBrowser来显示地图或任何其他事情。 事实上,这是一个意见问题,很可能你听到了人们的意见,告诉你不要这样做。 不幸的是,堆栈溢出是一个问题/答案网站,所以像这样的问题不一定是可行的。 TWebBrowser包装一个Internet Explorer浏览器窗口,并依赖于安装的任何版本的IE。 您可以在Internet Explorer中打开的任何内容也可以在包含Google地球的TWebBrowser打开。 这是一个指向页面并加载它的问题。 至于技术上的原因,这里和 ...
-
在Delphi TWebBrowser中按地址显示Google Map(Display Google Map by address in Delphi TWebBrowser)[2023-10-13]
您无法在创建网页时加载网页。 相反,您可以使用TTimer在延迟时加载它... procedure TForm1.Timer1Timer(Sender: TObject); begin Timer1.Enabled:= False; //Disable timer so it doesn't fire again WebBrowser1.Navigate('about:blank'); ........... end; You cannot load a web page at the t ... -
如果要将地址传递给映射表单,可以将其作为表单构造函数的参数传递。 创建名为fAddress的私有表单变量。 然后添加表单的Public Constructor覆盖传递地址: Public constructor create(AOwner: TComponent; AAddress: string); reintroduce; implementation constructor TForm1.create(AOwner: TComponent; AAddress: string); beg ...
-
您要搜索的事件是OnDownloadBegin和OnDownloadComplete。 OnDownloadBegin在文档开始下载之前触发,因此是启动某些加载动画的最佳事件。 http://docwiki.embarcadero.com/Libraries/XE8/en/SHDocVw.TWebBrowser.OnDownloadBegin 下载文档后,OnDownloadComplete将触发,即使文档下载由于某种原因而失败。 所以最好甚至停止一些加载动画。 http://docwiki.embarca ...
-
将Silent属性设置为True Set Silent property to True
-
TWebBrowser 已经在一个单独的线程中下载了东西。 您的程序在下载时应该已经保持响应。 你可以看到这个,因为频繁的模式是设置URL,然后等待下载完成: WebBrowser1.Navigate(...); while WebBrowser1.Busy do Application.ProcessMessages; 这使用ProcessMessages ,所以我不能真诚地推荐它。 要在下载完成时得到通知,而不是像代码那样进行轮询,请处理控件的OnNavigateComplete2事件。 请注意, ...
-
Delphi - TWebBrowser中的证书错误,IE9中没有错误(Delphi - Certificate error in TWebBrowser, no error in IE9)[2022-08-10]
(在David Heffernan的评论之后我改写了我的答案。) 解决方法 在“Internet Options \ Advanced \ Security”中关闭“检查服务器证书吊销 ”消除了TWebBrowser的证书错误页面。 请注意,关闭撤销检查会打开一个安全漏洞(感谢David Heffernan在他的评论中强调这一点)。 2. Windows XP和7之间的区别 不同的行为是由于默认情况下在Windows XP上关闭此选项 ,但在Windows 7上它已打开。 奇怪的是,在不同的操作系统版本上, ... -
你应该留意其他海报的预订,但如果你想要一个启动TWebBrowser的dll,这应该让你开始。 它编译并运行,但只是经过了非常简单的测试。 希望有所帮助。 library BrowserDLL; uses ShareMem, SysUtils, Classes, Forms, Windows, DLLMainForm in 'DLLMainForm.pas' {MainForm}; {$R *.RES} function ShowBrowserForm(AHandle: THa ...