importasynciofromkademlia.networkimportServerasyncdefrun():# Create a node and start listening on port 5678node=Server()awaitnode.listen(5678)# Bootstrap the node by connecting to other known nodes, in this case
def create_database(cursor): try: cursor.execute( "CREATE DATABASE {} DEFAULT CHARACTER SET 'utf8'".format(DB_NAME)) except mysql.connector.Error as err: print("Failed creating database: {}".format(err)) exit(1) try: cursor.execute("USE {}".format(DB_NAME)) except mysql.connector...
def handle_indicator_response( addon: Any, request_id: int, indicator_id: int ) -> None: """ This function is called after you create an indicator, in response to `register_indicator`. :param addon: The addon state object that you received when calling `create_addon`. :param request_...
As we did in Chapter 2, we will use the precision-recall curve, the average precision, and the auROC as our evaluation metrics. Here is the function that will plot these results: def plotResults(trueLabels, anomalyScores, returnPreds = False): preds = pd.concat([trueLabels, anomalyScores...
Other time-delay-dependent complexity estimates can be plugged in here, all made available via NeuroKit2 API. # UDF compute_HRV # This UDF computes all [regular and extra non-linear] HRV metrics segment-wise for a file def compute_HRV(peaks,rri,SubjectID): # Regular HRV matrix (from ...
In this example, the Calculate Value tool returns a value of 12 Kilometers for use with the Buffer tool. Expression: fn("%A%", "%B%") Code Block: def fn(a, b): distance = int(a) * int(b) return f"{distance} Kilometers" ArcPy ArcPy is an Esri Python site pack...
执行和前面的一样,需要在命令行里面,输入python ex20.py ex20.txt下面代码中,如果复制后,空格没有了,你要自己手动加上。(例如下面的第四行前面有4个空格)from sys import argvscript, input_file = argvdef print_all(f): print (f.read())def rewind(f): f.seek(0)def print_a_line(line_count,...
cd~/aws-iot-device-sdk-python-v2/samples python3 pubsub.py --topic topic_1 --ca_file ~/certs/Amazon-root-CA-1.pem --cert ~/certs/device.pem.crt --key ~/certs/private.pem.key --endpointyour-iot-endpoint You should see the same output as you saw in theGetting started tutorial. ...
from django.contrib.auth.decorators import permission_required @permission_required("polls.add_choice", login_url="/loginpage/") def my_view(request): ... As in the login_required() decorator, login_url defaults to settings.LOGIN_URL. If the raise_exception parameter is given, the decorator...
def DCNCallback(message): print "Notification:" for tab in message.tables: print "Table:", tab.name for row in tab.rows: if row.operation & cx_Oracle.OPCODE_INSERT: print "INSERT of rowid:", row.rowid if row.operation & cx_Oracle.OPCODE_DELETE: print "DELETE of rowid:", row.rowid...