我使用if (completedTask == readByteTask)
{
// Throw an exception if there was a read error or cancellation.
await readByteTask;
var byte = buf[0];
...
// Continue reading
readByteTask = stream.ReadAsync(buf, 0, 1, token);
}
else if (completedTask == keepAliveTimerTask)
{
// Throw an exception if there was a cancellation.
await keepAliveTimerTask;
...
// Restart keepalive timer.
keepAliveTimerTask = Task.Delay(TimeSpan.FromSeconds(10), token);
}
else if (completedTask == messageTask)
{
// Throw an exception if there was a cancellation (or the SendQueue was marked as completed)
byte[] message = await messageTask;
...
// Continue reading
messageTask = SendQueue.ReceiveAsync(token);
}
为regx搜索构建以下模式。虽然它在构建器站点中工作正常,但它似乎在我的python脚本中失败了。追溯建议https://regex101.com/#python
AttributeError: 'NoneType' object has no attribute 'group'
答案 0 :(得分:3)
在第二个替代表达式Address(.*?)(?=\\nRegDate:)
中,您似乎希望.
匹配任何字符,包括换行符,这不是它的正常含义。
试试这个:
address_t = re.compile(pattern_string, re.DOTALL)