Почему мой код отлично работает на моем компьютере, но не на моем Raspberry Pi?Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Почему мой код отлично работает на моем компьютере, но не на моем Raspberry Pi?

Сообщение Anonymous »


Идеальный вывод на ПК, а не на pi. < /li>
Работает, как и ожидалось, а не на Pi.
Просмотр кода и вывода: < /li>
< /ol>
Я попытался повторить скопирование по коду, но он все еще не работал. Outptu on the Pi интересна: < /p>
Current message: 0
Current message: 0
Current message: 0
Current message: 0
Current message: 0
Current message: 0
Current message: 0
Current message: 0
Current message: 0
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
Current message: 1
... the ones continue.
< /code>
Не то, что я ожидал.
код точно такой же: < /p>
import scratchattach as sa
import time
import warnings

# Optional: suppress login warnings
warnings.filterwarnings('ignore', category=sa.LoginDataWarning)

# Login with username/password (or use session ID for stability)
USERNAME = "my username"
PASSWORD = "my password"
PROJECT_ID = 1207157729 # https://scratch.mit.edu/projects/1207157729/

session = sa.login(USERNAME, PASSWORD)

# Connect to the project cloud variables
cloud = session.connect_scratch_cloud(PROJECT_ID)

LAST_MESSAGE = ""

while True:
# Read the "toserver" cloud variable
current_message = cloud.get_var("toserver")
print(f"Current message: {current_message}") # debug

if str(current_message).strip() != "" and str(current_message) != "0":
print(f"New message received: {current_message}")

# Respond back
cloud.set_var("response", 1)

# Clear the message
cloud.set_var("toserver", 0)

time.sleep(0.5) # Avoid spamming Scratch


Подробнее здесь: https://stackoverflow.com/questions/797 ... spberry-pi
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»