Created
April 20, 2018 12:09
-
-
Save wwj718/4bd81877f4155b70beb5a596dafc893c to your computer and use it in GitHub Desktop.
strip bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from microbit import * | |
def get_topic_and_data(b): | |
try: | |
c = b.rstrip() | |
sleep(10) | |
# c = b.split(b"\r\n")[0] | |
# uart.write(b) | |
# uart.write(b'{"a": 18}\r\n') # 稳定 | |
uart.write(c + b'\r\n') | |
# json_str = str(b, 'utf-8') | |
# json = eval(json_str) | |
# display.show(str(json["a"])[-1]) | |
return "a" | |
except: | |
pass | |
# uart.write(b'error\r\n') | |
# display.show(str("!")) | |
while True: | |
r = uart.readline() # is bytes or none | |
if r: | |
''' | |
try: | |
b = r | |
uart.write(b) | |
b = b.strip() | |
# uart.write(b+b"\r\n") | |
# uart.write(b+b"\r\n") | |
json_str = str(b, 'utf-8') | |
json = eval(json_str) | |
except: | |
pass | |
# uart.write(b'error\r\n') | |
''' | |
d = get_topic_and_data(r) | |
if d: | |
pass | |
# uart.write(bytes(d,'utf-8')+b'\r\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
看去是 切割的时候 \n\r ,被输入捡过去