Grep a word and find its Count from log file for different times

log file which contains following data. 2014-10-19 17:30:25: Creating destination directory: "master1usersjameskJavachapter05tech-support-completedoc" Loading source file Error \master1usersjameskJavachapter05tech-support-completeJamesKohout.java... onstructing Javadoc information...Error 31 Error Standard Doclet version 1.6.0_26 Error -encoding Error 19 windows-1252 20 -charset Error 21 wind

刷新一个单词并从不同时间的日志文件中找到它的计数

包含以下数据的日志文件。 2014-10-19 17:30:25: Creating destination directory: "master1usersjameskJavachapter05tech-support-completedoc" Loading source file Error \master1usersjameskJavachapter05tech-support-completeJamesKohout.java... onstructing Javadoc information...Error 31 Error Standard Doclet version 1.6.0_26 Error -encoding Error 19 windows-1252 20 -charset Error 21 windows-1252 22 -d

Python: Importing a module with the same name as a function

For background: First time asking a question on SE. I'm still quite new at Python, and not very experienced with programming in general. I've searched around but I haven't found an answer to this question, and I'd greatly appreciate your help. My question is: How can I import a module which has the same name as a function? To be specific, I am working with the Python symboli

Python:导入与函数名称相同的模块

作为背景:第一次提出关于SE的问题。 我对Python仍然很陌生,对编程一般也不太熟悉。 我搜索了四周,但我还没有找到这个问题的答案,我非常感谢你的帮助。 我的问题是:如何导入与函数名称相同的模块? 具体来说,我正在使用Python 2.7与Python符号数学库sympy 0.7.5合作。 Sympy有这样的结构: sympy | +-- __init__.py +-- simplify | +-- __init__.py +-- simplify.py | |

How to write a numpy matrix in a text file

Suppose I am getting a numpy matrix from some calculation. Here is my numpy matrix 'result1':: result1= [[ 1. 0. 0. 0.00375 -0.01072 -0. -1000. ] [ 2. 3. 4. 0. -0.004 750. 0. ] [ 3. 3. 0. 0. 0. -750. 1000. ]] Now I want to write this m

如何在文本文件中编写一个numpy矩阵

假设我从一些计算中得到了一个numpy矩阵。 这里是我的numpy矩阵'result1':: result1= [[ 1. 0. 0. 0.00375 -0.01072 -0. -1000. ] [ 2. 3. 4. 0. -0.004 750. 0. ] [ 3. 3. 0. 0. 0. -750. 1000. ]] 现在我想将这个矩阵写入一个名为'result.txt'

Cannot sort by duplicate column

When I sort one of my dataframes, eg: my_df.sort(['column_A', 'column_B']) I get: ValueError: Cannot sort by duplicate column ['A', 'B'] The columns have different data and different names. Here is the full error: /Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/pandas/core/frame.pyc in sort(self, columns, column, axis, ascending, inplace) 2534 colum

无法按重复列排序

当我对我的一个数据框进行排序时,例如: my_df.sort(['column_A', 'column_B']) 我得到: ValueError: Cannot sort by duplicate column ['A', 'B'] 这些列有不同的数据和不同的名称。 这是完整的错误: /Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/pandas/core/frame.pyc in sort(self, columns, column, axis, ascending, inplace) 2534 columns = column 2535

PyQt: Detect resizing in Widget

I create a simple UI with Qt Designer and convert it to Python codes. I searched for any method to detect changing window size. This is the generated code : from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def onResize(event): print(event) def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setWindowTitle("M

PyQt:在Widget中检测调整大小

我使用Qt Designer创建一个简单的UI并将其转换为Python代码。 我搜索了任何方法来检测窗口大小的变化。 这是生成的代码: from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def onResize(event): print(event) def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setWindowTitle("MainWindow") MainWindow.resize(200,

pyqt: Lower dock widget

I am trying to find a way to lower a dock widget so just the title bar is showing. Right now I am just trying to hide the widget inside the dock widget but I am getting this: the dock widget "lowers" but the width doesn't stretch across the whole screen, is there a way I can fix that? Or some other way of lowering a dock widget? Here is the code for the window: class Ui_MainW

pyqt:较低的码头小部件

我试图找到一种方法来降低码头小部件,以便标题栏显示。 现在我只是试图在小部件里面隐藏小部件,但是我得到了这个: 码头小部件“降低”,但宽度不能在整个屏幕上延伸,有没有办法解决这个问题? 或者降低码头小部件的其他方式? 这是窗口的代码: class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(320, 240)

pyqt: Focus widget when mainwindow is clicked

I have a widget that I open when I click a button, but when I click somewhere else (eg another program) and then click back to the main window the widget doesn't show up with it, I mean it is there but it is behind the program I clicked when it lost focus. Is there a way to make the widget "focus" when the main windows is clicked after it lost focus. Edit: I am creating the men

pyqt:单击主窗口时的焦点窗口小部件

我有一个小部件,当我点击一个按钮时打开,但当我点击其他地方(例如另一个程序),然后单击回主窗口小部件不会显示出来,我的意思是它在那里,但它是当它失去焦点时,我点击该程序的后面。 是否有一种方法可以在失去焦点后单击主窗口时使窗口小部件“聚焦”。 编辑: 我正在创建这样的菜单: def FindDialog(self): self.w_2 = includes.CtrlF.MainWindow(self) # display find text window self.w_2.show() 这里是窗

How to display a window on a secondary display in PyQT?

I am developing an application; which will run on a system with 2 displays. I want my PyQt app to be able to automatically route a particular window to the second screen. How can this be done in Qt? (either in Python or C++) Use QDesktopWidget to access to screen information on multi-head systems. Here is pseudo code to make a widget cover first screen. QDesktopWidget *pDesktop = QAppli

如何在PyQT的辅助显示器上显示一个窗口?

我正在开发一个应用程序; 它将在具有2个显示器的系统上运行。 我希望我的PyQt应用能够自动将特定窗口路由到第二个屏幕。 这怎么能在Qt中完成? (在Python或C ++中) 使用QDesktopWidget访问多头系统的屏幕信息。 这里是伪代码,使一个部件覆盖第一个屏幕。 QDesktopWidget *pDesktop = QApplication::desktop (); //Get 1st screen's geometry QRect RectScreen0 = pDesktop->screenGeometry (0); //Move the wid

pyqt: how to remove a widget?

I have a QGroupBox widget with children in it that I want to remove. How do I do that? I can't find any removeWidget , removeChild , removeItem , or anything similar in the docs. I can only see how to remove things from a layout, but that, apparently, doesn't remove it from the actual widget. If your widget have no child widgets that depend on it i think you can use: layout.removeWi

pyqt:如何删除一个小部件?

我有一个QGroupBox小部件,其中包含要删除的子项。 我怎么做? 我无法找到任何removeWidget , removeChild , removeItem或类似的文档。 我只能看到如何从布局中删除东西,但显然,它并没有从实际的部件中删除它。 如果你的小部件没有依赖它的子部件,我认为你可以使用: layout.removeWidget(self.widget_name) self.widget_name.deleteLater() self.widget_name = None 在我的测试中,当它是一个有孩子的小部件时,你

Positioning and Displaying a Custom Widget

I am attempting to use PyQT to position and display a custom widget. Thus far, I have a widget, and my window. I have been successful in displaying the widget through a layout, however, I am interested in using .move(x,y,) to position my widget before show()'ing it. Thus far my code is as follows: import sys, random from PyQt4 import QtGui, QtCore # Robot Widget class RobotLink(QtGui.QWi

定位和显示自定义小部件

我正在尝试使用PyQT来定位和显示自定义小部件。 到目前为止,我有一个小部件和我的窗户。 我已经成功地通过布局显示小部件,但是,我有兴趣使用.move(x,y)在show()之前放置我的小部件。 到目前为止,我的代码如下所示: import sys, random from PyQt4 import QtGui, QtCore # Robot Widget class RobotLink(QtGui.QWidget): def __init__(self, parent, x, y, width, height, fill): super(RobotLink, sel