Files
python_tools/updata/task_table_fun.py

44 lines
962 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def is_number(s:str):
try: # 如果能运行float(s)语句返回True字符串s是浮点数
float(s)
return True
except ValueError: # ValueError为Python的一种标准异常表示"传入无效的参数"
pass # 如果引发了ValueError这种异常不做任何事情pass不做任何事情一般用做占位语句
try:
import unicodedata # 处理ASCii码的包
unicodedata.numeric(s) # 把一个表示数字的字符串转换为浮点数返回的函数
return True
except (TypeError, ValueError):
pass
return False
# 任务0的输入函数逗号隔开,输入小数
def input_task0(text:str):
ret=bytearray()
sp=text.split(",")
for i in sp:
if(is_number(i)):
num=int(float(i)*10)
ret.append(num&0xff)
ret.append((num>>8)&0xff)
return ret
# 解析任务0的返回值
def output_task0(data:bytearray):
pass