代码:
postgres=# create role hello;
CREATE ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
hello | Cannot login | {}
postgres | Superuser, Create role, Create DB, Replication | {}
postgres=# ALTER ROLE hello WITH LOGIN;
ALTER ROLE
postgres=# ALTER ROLE hello WITH CREATEDB;
ALTER ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
hello | Create DB | {}
postgres | Superuser, Create role, Create DB, Replication | …
Run Code Online (Sandbox Code Playgroud) 我试图Scapy
从一开始就使用Python来分析数据包.在最近的搜索中,我发现python中有另一个名为的模块dpkt
.使用此模块,我可以解析数据包的各个层,创建数据包,读取.pcap
文件并写入.pcap
文件.我发现他们之间的区别是:
缺少实时数据包嗅探器 dpkt
某些字段需要使用struct.unpack
in 解压缩dpkt
.
我还缺少其他差异吗?
import unittest
class A(unittest.TestCase):
def setUp(self):
print "Hi it's you",self._testMethodName
def test_one(self):
self.assertEqual(5,5)
def tearDown(self):
print "Bye it's you", self._testMethodName
class B(A,unittest.TestCase):
def setUp(self):
print "Hi it's me", self._testMethodName
def test_two(self):
self.assertNotEqual(5,5)
unittest.main()
Run Code Online (Sandbox Code Playgroud)
输出 :
Hi it's you test_one
Bye it's you test_one
.Hi it's me test_one
Bye it's you test_one
.Hi it's me test_two
FBye it's you test_two
======================================================================
FAIL: test_two (__main__.B)
----------------------------------------------------------------------
Traceback (most recent call last):
File "try_test_generators.py", line 19, in test_two
self.assertNotEqual(5,5)
AssertionError: 5 == 5 …
Run Code Online (Sandbox Code Playgroud) 我有一组由应用程序创建的 100 个文件。文件不是按顺序动态更新的。使用 Python,我正在尝试读取文件。但是,我不知道哪个文件在什么时间更新。
我不想每次都遍历每个文件来检查实例中更新了哪些文件。我可以创建多个进程/线程来触发文件更新的主进程。有没有其他方式像文件更新可以通知主python进程,以便只读取那些文件??
谢谢。
代码:
CREATE FUNCTION square_num(num integer)
RETURNS INTEGER AS $$
BEGIN
IF (num<0) THEN
RETURN 0;
END IF;
RETURN num*num;
END; $$
LANGUAGE PLPGSQL;
Run Code Online (Sandbox Code Playgroud)
上面的代码在数据库postgres
和模式中创建了一个函数public
.如何在特定数据库及其架构中创建函数?谢谢.