OK, I'm new to Python, and creating simple tabs in this language is somewhat distracting me. Trying to get a tabulated output like this:
: 0.1 A: 0.1: 0.9H: 2.2 I: 3.0B: 0.2: 0.5C: 0.3D: 0.4 This is the name of the node, a colon, ':', and its related distance, the nodes have been nominated by 'none' and this is because they are only for one more variable Represented distance Let's do this is a tree design, so tabs and indentations may vary. I represent this information with name variables from
self.name , and a
self Distance Distance representation
An inherent output of information looks like the following:
A: 0.1H: 2.2 : 3.0 B: 0.2 None: 0.9 C: 0.3 D: 0.4 None: 0.5 None: 0.1 Indentation should have 3 levels,
The root, ': 0.1',
3 children of 'A: 0.1'; ': 0.9'; ': 0.5',
And ': 0.9' and ': 0.5 children, H, I, B, C and D
I apologize that this is not enough information I am just unsure how to make an original tabbed output like how I have shown above.
Thank you!
Edit: Thank you for receiving my reply!
Assume that you have a data structure like a tree, I have nested words in this example for plainness I'm going to use:
data = {"A": {"value": 0.2, "children": {"D": {"value": 0.3, "kids" {"Value": {"value": 0.4 "children"): {"H": {"value": 0.5, "children": {}}, "I" {"value": 0.6, "Children": {}}}}}, "b": {"value": 0.7, "children": {"c": {"value": 0.8, "child": "{}}," D ": {" Value ": 0.9," children ": {}}}}} You can use it by using the following recursive function Import printers from the operators (tree, depth = 0): prepaid = "\ t" * Depth, for the key, sorted (tree. Etams).
) Values ['Children']: Performance (Val ['children'], Depth + (format): Values: "{0} {1}: {2}". Format (prepaid, key, value ['value']) 1)
which displays the following output:
& gt; & gt; display: data A: 0.2 d: 0.3 e : 0.4 H: 0.5I: 0.6B: 0.7C: 0.8D: 0.9> & Gt; & Gt;
Comments
Post a Comment