Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
python [2019/07/09 17:15]
paul [Plane Notes]
python [2019/07/09 17:29] (current)
paul [Formatting]
Line 169: Line 169:
   * ''%%strip()%%''   * ''%%strip()%%''
   * ''%%split()%%''   * ''%%split()%%''
 +
 +==== Formatting ====
 +
 +If you want to print a neat line of data use the [[https://docs.python.org/2/library/string.html#format-string-syntax|Format String Syntax]].
 +
 +For example: 
 +<code python>
 +print("[ FAIL ] {: <20} Channel: {: <20} Statistics: {:>6.4f} hz".format(description, chan, stats))
 +</code>
 +
 +This sets a fix width for each field and aligns the test either left ''%%<%%'' or right ''%%>%%''
  
 ===== Mutability ===== ===== Mutability =====
  • python.1562692532.txt.gz
  • Last modified: 2019/07/09 17:15
  • by paul