NP,NP-Complete和NP-Hard有什么区别?
我知道网上有很多资源.我想阅读你的解释,原因是它们可能与那些不同,或者有些东西我不知道.
我将在 IPv4 地址上运行 grpc 服务器,如下所示:
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
protoc_pb2_grpc.add_ProtocServicer_to_server(StockProtocServicer(), server)
server.add_insecure_port('0.0.0.0:5000')
server.start()
Run Code Online (Sandbox Code Playgroud)
但它正在监听 IPv6。以下是 的输出lsof -i -n -P | grep 5000:
python 7302 dev 6u IPv6 224100 0t0 TCP *:5000 (LISTEN)
Run Code Online (Sandbox Code Playgroud)
我已经测试了 IPv6 上的监听,看看会发生什么,如下所示:
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
protoc_pb2_grpc.add_ProtocServicer_to_server(UserProtocServicer(), server)
server.add_insecure_port('[::]:5000')
server.start()
Run Code Online (Sandbox Code Playgroud)
但结果是一样的:
python 7366 dev 6u IPv6 225782 0t0 TCP *:5000 (LISTEN)
Run Code Online (Sandbox Code Playgroud)
我还尝试使用实际的 IP 地址而不是0.0.0.0:
python 7392 dev 6u IPv6 226111 0t0 TCP 192.168.1.23:5000 (LISTEN)
Run Code Online (Sandbox Code Playgroud)
尽管我可以在客户端上使用服务器的 IPv4 地址,但我只想在 IPv4 上运行服务器。我怎样才能做到这一点?
我正在 android 27 模拟器上进行测试并尝试遍历一些目录。
当我尝试遍历/storage/emulated目录时,该方法会在存在时listFiles()返回。null/storage/emulated/0
这是一个测试代码:
File emuDir = new File("/storage/emulated");
File[] emuDirFiles = emuDir.listFiles(); // returns null.
File exStorageDir = new File("/storage/emulated/0")
exStorageDir.exists(); // returns true
Run Code Online (Sandbox Code Playgroud)
PS我已经在清单中添加了适当的存储权限并授予了运行时权限。
java android file-permissions android-6.0-marshmallow android-storage
在阅读JDK源代码时,我发现有些方法是原生的,但是在它们的静态块中没有System.loadLibrary或System.load,那么这些方法实际上是如何加载的?
所以我猜这些方法是内置在 JVM 中的。只是想知道它们是如何为特定类加载的。说,StrictMath。如下:
public final StrictMath {
public static native double cos(double a);
}
Run Code Online (Sandbox Code Playgroud)
所以我可以找到这个本地方法的源代码,只是想知道它是如何为这个特定类加载的。
假设我要使用Python修改以下XML ElementTree:
<root xmlns:prefix="URI">
<child company:name="***"/>
...
</root>
Run Code Online (Sandbox Code Playgroud)
我正在对XML文件进行如下修改:
import xml.etree.ElementTree as ET
tree = ET.parse('filename.xml')
# XML modification here
# save the modifications
tree.write('filename.xml')
Run Code Online (Sandbox Code Playgroud)
然后,XML文件如下所示:
<root xmlns:ns0="URI">
<child ns0:name="***"/>
...
</root>
Run Code Online (Sandbox Code Playgroud)
如您所见,namepsace prefix更改为ns0。我知道这里ET.register_namespace()提到的使用。
问题ET.register_namespace()在于:
prefix和URI例如,如果xml看起来像:
<root xmlns="http://uri">
<child name="name">
...
</child>
</root>
Run Code Online (Sandbox Code Playgroud)
它将转换为以下内容:
<ns0:root xmlns:ns0="http://uri">
<ns0:child name="name">
...
</ns0:child>
</ns0:root>
Run Code Online (Sandbox Code Playgroud)
如您所见,默认名称空间更改为ns0。
有什么办法解决这个问题ElementTree吗?
java ×2
python ×2
android ×1
elementtree ×1
grpc ×1
jvm ×1
np ×1
np-complete ×1
np-hard ×1
xml ×1
xml-parsing ×1