[英]What does 'File "<string>"' stands for on python debugger and traceback?
[英]Python traceback: File “<string>”. What does it mean?
好吧,顯然我是新來的。 我得到了這個Python追溯:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 30
SyntaxError: invalid syntax
File "<string>"
代表什么?
我的代碼在第30行有一個空行,所以我假設這不是我的代碼,但是它指的是什么?
(我在ESP8266上使用Micropython)
這是我的代碼:
import network
import tinyweb
import machine
# Connect to your WiFi AP
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('blabla', 'blabla')
# Create web server application
app = tinyweb.webserver()
count = 0
# Hello world index page (just to be sure - let's handle most popular index links)
@app.route('/')
@app.route('/index.html')
async def index(req, resp):
await resp.start_html()
await resp.send('<html><body><h1>Hello, world!</h1></html>\n')
# Counter REST API endpoint
@app.resource('/counter')
def counter(data):
return {'name': 'Foo', 'counter': counter}
def pin_handler(p)
global count
count =count + 1
#pin=machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP)
#pin.irq(handler = pin_handler, trigger = Pin.IRQ_FALLING, hard = True)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80)
多虧了buran,我找到了原因。 <string>
顯然只引用了我自己的代碼。 我忘了在pin_handler函數的和處添加一個冒號,並且以某種方式將錯誤發生的位置向下移動了...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.