我已经开始使用 Visual Studio 代码进行远程调试,但我无法让它工作。远程和本地开发 PC 都运行 4.1.3 版 ptvsd。远程机器有脚本:import ptvsdptvsd.enable_attach()#Enable the below line of code only if you want the application to wait untill the debugger has att$#ptvsd.wait_for_attach()import randomguesses_made = 0name = input('Hello! What is your name?\n')number = random.randint(1, 20)print('Well, {0}, I am thinking of a number between 1 and 20.'.format(name))while guesses_made < 6: guess = int(input('Take a guess: ')) guesses_made += 1 if guess < number: print('Your guess is too low.') if guess > number: print('Your guess is too high.') if guess == number: breakif guess == number: print('Good job, {0}! You guessed my number in {1} guesses!'.format(name, guesses_made))else: print('Nope. The number I was thinking of was {0}'.format(number))本地计算机是:import ptvsdptvsd.enable_attach(address = ('192.34.98.197',3000))#Enable the below line of code only if you want the application to wait untill the debugger has attached to it#ptvsd.wait_for_attach()import randomguesses_made = 0name = input('Hello! What is your name?\n')number = random.randint(1, 20)print('Well, {0}, I am thinking of a number between 1 and 20.'.format(name))while guesses_made < 6: guess = int(input('Take a guess: ')) guesses_made += 1 if guess < number: print('Your guess is too low.') if guess > number: print('Your guess is too high.') if guess == number: breakif guess == number: print('Good job, {0}! You guessed my number in {1} guesses!'.format(name, guesses_made))else: print('Nope. The number I was thinking of was {0}'.format(number))我已将条目添加到 launch.json 中:{ "name": "Attach (Remote Debug)", "type": "python", "request": "attach", "localRoot": "${workspaceRoot}", "remoteRoot": "/home/pi/testdebug/", "port": 3000, "secret": "my_secret", "host":"localhost"},
添加回答
举报
0/150
提交
取消