gi

正则API

安稳与你 提交于 2020-03-03 05:50:11
正则表达式:规定字符串中字符出现规律的公式 如果备选字符列表中个别字符之间是连续的,可用-省略中间的字符。比如: 匹配1位数字:   [0-9] 匹配1位小写字母 : [a-z] 匹配1位大写字母 : [A-Z] 匹配1位字母 :   [a-zA-Z] 匹配1位汉字: [\u4e00-\u9fa5] 字符集开头,使用^表示除了xx,但除xx外一切字符都行!范围太大了。 预定义字符集: 对常用字符集的简化标识 [0-9] 一位数字 :           \d [0-9A-Za-z_] 一位字母,数字或下划线: \w 换行,空格,tab 一位空字符 : \s 除回车换行外,任意一个字符     . 量词:规定字符集出现次数的规则 用于字符集之后,默认修饰相邻的前一个字符集 有明确数量的量词: 最少m次,最多n次   : {m,n} 最少m次,多了不限   : {m,} 必须m次        : {m} 没有明确数量的量词: 可有可无,最多1次    ? 可有可无,多了不限    * 至少一次,多了不限   + 正则中如果正文和正则保留字冲突,也可用\转义 5. 分组和选择: 选择:或 正则1|正则2 只要满足任意一个正则即可 分组: () ()扩起的子表达式称为一组 数量词放在()之后,则修改一组出现的次数 如: (去){2} *****分组编号: 正则中每个()

【AW346】走廊泼水节

两盒软妹~` 提交于 2020-02-02 22:46:56
题目链接: https://www.acwing.com/problem/content/348/ 题目大意:给定一棵 \(n\) 个节点的树,要求增加若干条边,把这棵树扩充为完全图,并满足图的唯一最小生成树仍然是这棵树, 求增加的边的权值总和最小是多少 solution 很显然 , 对于增加一条连接 \(a_i\) , \(b_i\) 的边 , 要满足图的唯一最小生成树仍然是这棵树 , 它的边权至少为 \(max\left\{dis(u , v)\right\}(u , v \in Path(a_i , b_i)) + 1\) , 只要枚举每一条边 , 求出最小值并求和即可 时间复杂度 : \(O(n^2logn)\) 感觉上面那个算法不太好写 , 而且时间复杂度也不够优秀... 于是可以换种思路 , 考虑 \(kruscal\) 的过程 , 对于一条连接 \(a_i\) , \(b_i\) , 权值为 \(w_i\) 的边 , 它连接起了 \(a_i\) , \(b_i\) 所在的两个连通块 , 对于这两个连通块之间的边的权值一定不会小于这条边 , 设这两个连通块的大小为 \(size_a\) , \(size_b\) , 则这两个连通块之间的连边的总权值最小为 \((size_a \times size_b - 1) \times (w_i + 1)\) , 模拟 \

题解【Vijos1159】岳麓山上打水

拥有回忆 提交于 2020-02-01 13:22:24
题面 迭代加深搜索模板题。 注意开始时要先对桶的容量从小到大排序。 达到搜索层数时使用完全背包 \(\text{check}\) 即可。 具体实现参考代码。 #include <bits/stdc++.h> #define itn int #define gI gi using namespace std; inline int gi() { int f = 1, x = 0; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();} while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return f * x; } const int maxn = 103, maxm = 20003; int d;//要搜索的层数 int mb, n, m, p, q[maxn], a[maxn], ans[maxn], sum; bool f[maxm]; inline bool check()//完全背包check { memset(f, false, sizeof(f)); f[0] = true; for (int i = 1; i <= d; i+=1) { for (int j = 0; j

PyGObject for Python 3.5.1?

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Debian Linux, and I have the package python3-gi installed from Synaptic, and this works fine if I use my Python 3.4 interpreter. But, when I run a Gtk+3 program using 3.5, it gets stuck at the from gi.repository import Gtk line, saying there's no module named Gtk. Additionally, I don't think that pip works for Python 3.5 on my computer, although I'm not sure. I just know that pip install PyGObject doesn't work. Finally, when I try to use Pycharm's specific package installer (Settings/Project Interpreter), Pycharm tells me that I

Meld error “Cannot import: GTK+; No module named repository”

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Meld used to work on my machine (openSuse Linux 13.1, Python 2.7.6) but after having trouble with Spyder (like it refusing to actually run any scripts), I uninstalled a large number of things, then slowly brought them back again. Since then, meld does not work anymore. I keep getting this error message > meld Cannot import: GTK+ No module named gi I was able to solve that by installing gi: > pip install gi Now the error is replaced by: > meld Cannot import: GTK+ No module named repository ... and here is a similar question where uninstalling

PyCharm can not resolve PyGObject 3.0, but code runs fine

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using PyCharm 2.5 on Ubuntu 11.10, trying to develop an application using PyGObject 3.0 on Python 3.2.2. I've installed the Ubuntu package python3-gobject, and when I run my code, it works exactly as expected. However, PyCharm can not seem to find any of the PyGObject modules. It says Unresolved refrence: 'Gtk' when I hover over Gtk in my import statement, and of course none of the auto-completion works. This is my code: #!/usr/bin/env python3 from gi.repository import Gtk win = Gtk.Window() win.connect("delete-event", Gtk.main_quit) win

AttributeError: &#039;module&#039; object has no attribute &#039;maketrans&#039;

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been doing some previous research about this error. There are some explanations here in StackOverflow related, the solutions suggested are quite unrelated though. When I try to import Gtk from gi.repository, it crashes with the following output: bash-4.2$ python3 Python 3.2 (r32:88445, Feb 21 2011, 21:11:06) [GCC 4.6.0 20110212 (Red Hat 4.6.0-0.7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from gi.repository import Gtk Traceback (most recent call last): File " ", line 1, in File "/usr/lib64

Python Gtk3 executable

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I started using Gtk3 with Python. I have one question: how I could make an executable windows file from my gtk3 python source using pyinstaller, cx_freeze or py2exe? I tried a lot of answers from stack overflow and many other web pages, but none worked. I tried to make it with pyinstaller (I think it could be the easiest way) and my source code looks like: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk class ButtonWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Button Demo") self.set_border

gi.repository Windows

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm developing an app which has to be 100% compatible on windows and on linux. On linux I have no problems, but on windows I came up with this message: from gi.repository import Gtk ImportError: No module named gi I installed pygobject, pygtkallinone, gtk.. what am I missing? 回答1: Most of Havok answer is correct, except that documentation has been improved a lot lately, with a Tutorial: http://python-gtk-3-tutorial.readthedocs.org/en/latest/ Including a PDF version for offline reading: http://media.readthedocs.org/pdf/python-gtk-3-tutorial

实验一:VLAN创建

匿名 (未验证) 提交于 2019-12-02 23:34:01
先创建两个交换机,左边交换机机连接四个PC,右边交换机机连接两个PC,再启动全部设备。接着给每个PC分别配上IPV4地址和掩码地址。然后先打开左边交换机的启动命令行终端。创建vlan 10和vlan 20,之后再用interface gi进入接口。 将PC3和PC4配置为vlan10,PC5和6配置为vlan20。 右边交换机也同样创建vlan 10和vlan 2。接着用interface gi进入接口,再将PC7配置为vlan10,PC8配置为vlan20。 最后再把两个交换机都用trunk模式。 左边交换机: system-view sysname r1 vlan 10 vlan 20 interface gi 1/0/1 port link-type access port access vlan 10 interface gi 1/0/2 port link-type access port access vlan 10 interface gi 1/0/3 port link-type access port access vlan 20 interface gi 1/0/4 port link-type access port access vlan 20 quit interface gi 1/0/48 port link-type trunk port trunk