这是我private async Task ButtonClickHandler(object sender, RoutedEventArgs args)
{
var urlList = new List<string>
{
"https://www.google.com/",
"https://www.facebook.com/",
"https://www.youtube.com/"
};
await LoopUrlsAsync(urlList);
}
private async Task LoopUrlsAsync(List<string> urlList)
{
TaskCompletionSource<bool> tcsNavigation = null;
TaskCompletionSource<bool> tcsDocument = null;
//These event bindings can be separated out to other methods, but for simplicity I've left them here.
WebBrowser.Navigated += (s, e) =>
{
tcsNavigation.SetResult(true);
};
WebBrowser.LoadCompleted += (s, e) =>
{
//Put logic here for what you want to happen when the document is finished loading
tcsDocument.SetResult(true);
};
foreach (var url in urlList)
{
tcsNavigation = new TaskCompletionSource<bool>();
tcsDocument = new TaskCompletionSource<bool>();
WebBrowser.Navigate(url);
await tcsNavigation.Task;
await tcsDocument.Task;
}
}
文件的代码,取自Bottle的文档。
server.py
当我尝试在终端中执行此操作时,当我执行此操作时
from bottle import route, run
@route('/hello')
def hello():
return "Hello World!"
run(host='localhost', port=8080, debug=True)
但是当我执行
python server.py
我收到以下错误:
python3 server.py
答案 0 :(得分:0)
听起来您已经将Bottle安装到了Python 2环境中,但是没有将Python 3环境安装到其中。 (它们是截然不同的;在一个软件包中安装软件包不会在另一个软件包中使用。)
尝试使用pip3 install bottle
或python3 -m pip install bottle
,看看是否可以解决该错误。