Thank you so much. Wasn't sure how to call the variable needed. This answered more than a few questions.Will the mqtt_server = b'secrets.MQTTSERVER' work? Using secrets.py for my internet/pass connection but sending in binary will that work as b'secrets.MQTTSERVER'?Code:
import secretswifi_ssid = secrets.SSIDwifi_password = secrets.PASSWORDmqtt_server = b'secrets.MQTTSERVER'#mqtt_server = b'MQTT_BROKER_URL'mqtt_username = b'BROKER_USERNAME'mqtt_password = b'BROKER_PASSWORD'
No. That will return the literal string b'secrets.MQTTSERVER'. You can see that by running the following:If the module you're importing defines that as a byte string it will remain a byte string unless you convert it to a "normal" (unicode) string. Either explicitly via bytes.decode() or implicitly depending on how you use it and manipulate it.Code:
foo = b'baz'bar = b'foo'print(foo, bar)
You may want to look at the python docs for url=https://docs.python.org/3.9/library/std ... tes.decode]bytes.decode()[/url] and [url=https://docs.python.org/3.9/library/std ... str.encode]str.edcode()[/url.
Statistics: Posted by eflwi — Sun Feb 09, 2025 11:24 pm