Google 应用引擎给我 400 错误请求状态代码?
在谷歌应用程序引擎中:
urlfetch.fetch('http://chart.apis.google.com/chart?chst=d_text_outline&chld=000000|12|h|FFFFFF|_|Tested: 21 Dec') works fine.
但是当我这样做时:
text = 'Tested: 21 Dec' // This ia a variable
my_url = 'http://chart.apis.google.com/chart?chst=d_text_outline&chld=000000|12|h|FFFFFF|_|'+text
urlfetch.fetch(my_url)
现在这给出了400错误
。我意识到这不能识别 |
之后的字符。因此,这只会调用 'http://chart.apis.google.com/chart?chst=d_text_outline&chld=000000|
有什么建议吗?
In google appengine:
urlfetch.fetch('http://chart.apis.google.com/chart?chst=d_text_outline&chld=000000|12|h|FFFFFF|_|Tested: 21 Dec') works fine.
But when i do this way:
text = 'Tested: 21 Dec' // This ia a variable
my_url = 'http://chart.apis.google.com/chart?chst=d_text_outline&chld=000000|12|h|FFFFFF|_|'+text
urlfetch.fetch(my_url)
Now this gives 400 error
. What I realize that this is not recognizing characters after |
. So, this makes call to only 'http://chart.apis.google.com/chart?chst=d_text_outline&chld=000000|
Any suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否是问题所在,但您应该在使用字符串构建 url 之前对其进行编码:
此外,在大多数情况下,最好使用字符串格式
'... %s' % (a,b) 或
''.join([a, b])
而不是a + b
。Not sure if this is the problem, but you should encode your strings before constructing url with them:
Also in most cases it is better practice to use string formatting
'... %s' % (a,b)
or''.join([a, b])
instead ofa + b
.