Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将文件路径参数传递给CherryPy_Python_Url_Cherrypy - Fatal编程技术网

Python 将文件路径参数传递给CherryPy

Python 将文件路径参数传递给CherryPy,python,url,cherrypy,Python,Url,Cherrypy,在CherryPy中,如何通过URL传递文件路径(即/abc/def/ghi)等参数?我想做一些类似http://...../filepath=“abc/def/ghi”。谢谢。使用~作为分隔符,然后将字符串中的~替换为/ http://...../filepath=abc~def~ghi def SomePage(self, filepath=None): filepath.replace('~', '/') return 'HelloWorld' 希望这有帮助 Andre

在CherryPy中,如何通过URL传递文件路径(即/abc/def/ghi)等参数?我想做一些类似
http://...../filepath=“abc/def/ghi”
。谢谢。

使用~作为分隔符,然后将字符串中的~替换为/

http://...../filepath=abc~def~ghi

def SomePage(self, filepath=None):
    filepath.replace('~', '/')
    return 'HelloWorld'
希望这有帮助


Andrew

嗯,
../a/b/x=y
发送值的方式是错误的,不管它是否是文件名。正确的方法是
../a/b?x=y

或者
../a/b/?x=y
,这将使
x
成为一个标准的查询参数,cherrypy也会这样对待它。此后,
x
的值是否有斜杠将是没有意义的。他们会很好地理解你的代码。

嗨,安德鲁,谢谢你的回复。事实上,这与CherryPy文档中建议的解决方法是一样的,而且很有效。但我想知道是否有办法通过保留斜杠的路径…同时我保留此解决方案,再次感谢。很高兴能提供帮助!欢迎光临!如果我的答案解决了你的问题,请将其标记为你接受的答案。