<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Print on 春江暮客</title>
    <link>https://www.bobobk.com/en/tags/print/</link>
    <description>Recent content in Print on 春江暮客</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sat, 01 Jun 2019 17:53:38 +0000</lastBuildDate>
    <atom:link href="https://www.bobobk.com/en/tags/print/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Summary of Python3 print function usage</title>
      <link>https://www.bobobk.com/en/323.html</link>
      <pubDate>Sat, 01 Jun 2019 17:53:38 +0000</pubDate>
      <guid>https://www.bobobk.com/en/323.html</guid>
      <description>&lt;p&gt;Python 3 makes the &lt;code&gt;print&lt;/code&gt; function more explicit compared to Python 2.&lt;/p&gt;&#xA;&lt;h2 id=&#34;1-outputting-strings-and-numbers&#34;&gt;&lt;strong&gt;1. Outputting Strings and Numbers&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;p&gt;&lt;code&gt;print(&amp;quot;runoob&amp;quot;)&lt;/code&gt; # Outputs string runoob&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;print(100)&lt;/code&gt; # Outputs number 100&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;str = &#39;runoob&#39;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;print(str)&lt;/code&gt; # Outputs variable runoob&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;L = [1,2,&#39;a&#39;]&lt;/code&gt; # List&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;print(L)&lt;/code&gt; &lt;code&gt;[1, 2, &#39;a&#39;]&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;t = (1,2,&#39;a&#39;)&lt;/code&gt; # Tuple&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;print(t)&lt;/code&gt; &lt;code&gt;(1, 2, &#39;a&#39;)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;d = {&#39;a&#39;:1, &#39;b&#39;:2}&lt;/code&gt; # Dictionary&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;print(d)&lt;/code&gt; &lt;code&gt;{&#39;a&#39;: 1, &#39;b&#39;: 2}&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;2-formatted-integer-output&#34;&gt;&lt;strong&gt;2. Formatted Integer Output&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Supports parameter formatting, similar to C language&amp;rsquo;s &lt;code&gt;printf&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;str &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;the length of (&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;%s&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;) is &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;%d&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;%&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;runoob&amp;#39;&lt;/span&gt;,len(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;runoob&amp;#39;&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(str) &lt;span style=&#34;color:#75715e&#34;&gt;# the length of (runoob) is 6&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Python String Formatting Symbols:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;** Symbol**&lt;/th&gt;&#xA;          &lt;th&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%c&lt;/td&gt;&#xA;          &lt;td&gt;Formats character and its ASCII code&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%s&lt;/td&gt;&#xA;          &lt;td&gt;Formats string&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%d&lt;/td&gt;&#xA;          &lt;td&gt;Formats signed decimal integer&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%u&lt;/td&gt;&#xA;          &lt;td&gt;Formats unsigned decimal integer&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%o&lt;/td&gt;&#xA;          &lt;td&gt;Formats unsigned octal number&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%x&lt;/td&gt;&#xA;          &lt;td&gt;Formats unsigned hexadecimal number (lowercase)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%X&lt;/td&gt;&#xA;          &lt;td&gt;Formats unsigned hexadecimal number (uppercase)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%f&lt;/td&gt;&#xA;          &lt;td&gt;Formats floating-point number, precision can be specified after decimal point&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%e&lt;/td&gt;&#xA;          &lt;td&gt;Formats floating-point number in scientific notation (lowercase &amp;rsquo;e&#39;)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%E&lt;/td&gt;&#xA;          &lt;td&gt;Same as %e, formats floating-point number in scientific notation (uppercase &amp;lsquo;E&amp;rsquo;)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%g&lt;/td&gt;&#xA;          &lt;td&gt;Shorthand for %f and %e&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%G&lt;/td&gt;&#xA;          &lt;td&gt;Shorthand for %f and %E&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;%p&lt;/td&gt;&#xA;          &lt;td&gt;Formats variable&amp;rsquo;s address in hexadecimal&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;&lt;strong&gt;Formatting Operator Auxiliary Directives:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
