在函数中使用特殊字符:Python

发布于 2024-10-10 03:20:11 字数 389 浏览 0 评论 0原文

我正在编写一个 xmlrpc 客户端,它使用用 ruby​​ 编写的服务器。其中一个函数是framework.busy?()。让我展示 ruby​​ 版本:

server.call( "framework.busy?" )  

假设我创建了一个 ServerProxy 类的实例,比如 server。那么在使用python调用函数busy时呢?我需要使用:

server.framework.busy?()  

这会导致错误:

SyntaxError: invalid syntax  

如何调用此函数?或者我错误地读取了 ruby​​ 代码并错误地实现了它。

I am writing an xmlrpc client which uses a server written in ruby. One of the functions is framework.busy?(). Let me show the ruby version:

server.call( "framework.busy?" )  

So lets assume I create an instance of the ServerProxy class say server. So while using python to call the function busy? I need to use:

server.framework.busy?()  

This leads to an error:

SyntaxError: invalid syntax  

How can I call this function? Or am I reading the ruby code wrong and implementing it wrongly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

也只是曾经 2024-10-17 03:20:11

我从来没有用问号来调用 XML 方法(并且我强烈怀疑它实际上可能超出了 XML-RPC 规范),但是尝试一下:

server.framework.getattr('busy?')()

我不知道这是否有效,并且您需要发布代码示例并有一个可以测试的工作服务器。 :)

无论如何,在方法名称中包含问号可能不是一个好主意,因此如果您可以将 Ruby 服务器修改为更合理的内容,那将会有所帮助。

I've never had to call XML methods with a question mark in (and I strongly suspect it might actually be outside XML-RPC specs), but try this:

server.framework.getattr('busy?')()

I have no idea of that works, and you would need to post a code example and have a working server I could test against. :)

In any case it's probably not a good idea to have a question mark in the method name, so if you can modify the Ruby server to something more sane, that would be helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文