简体   繁体   English

使用Python字典的正斜杠表示法

[英]Forward slash notation with Python dictionaries

I've never seen forward slash notation with Python dictionaries, and when looking to the official documentation, I couldn't find any reference, so I'm hoping someone can school me here. 我从来没有见过Python字典使用正斜杠表示法,而在查阅官方文档时,我找不到任何参考,因此我希望有人可以在这里学习。

I was playing with a new library I hope to use on a project when I ran across the notation: 当我遇到一个新的库时,希望能在项目中使用它:

object['/someKeyword']['/anotherKeyword'].someMethod() object ['/ someKeyword'] ['/ anotherKeyword']。someMethod()

I didn't understand what the bracketed terms meant at the time. 当时我不明白方括号内的含义。 A colleague helped me understand it was dictionary notation, but I haven't been able to find any follow up to study. 一位同事帮助我理解这是字典符号,但是我没有找到任何后续的学习方法。

Any information on the notation would be helpful! 关于该符号的任何信息都将有所帮助!

Those are strings, and you can have any unicode codepoint as string constituting character, which obviously includes / . 这些是字符串,您可以将任何unicode代码点作为字符串组成字符,其中显然包括/

In the example, it seems a dict like object is being accessed by subscription with string keys that start with / . 在示例中,看起来像dict这样的对象正在通过订阅以/开头的字符串键进行访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM