zoukankan      html  css  js  c++  java
  • 关于 水平制表符 Horizontal Tab (TAB)

    今天在学learn python the hard way ex26修改的时候,有一个关于 的问题,下面分别为代码以及输出结果:

     1 poem = """
     2 	The lovely world
     3 with logic so firmly planted
     4 cannot discern 
     the needs of love
     5 nor comprehend 	passion from intuition
     6 and requires an explantion
     7 
    		where there is none.
     8 """
     9 
    10 
    11 print "--------------"
    12 print poem
    13 print "--------------"
    --------------
    
            The lovely world
    with logic so firmly planted
    cannot discern
     the needs of love
    nor comprehend  passion from intuition
    and requires an explantion
    
                    where there is none.
    
    --------------
    

      可以看到,第二行的 以及第七行的两个 都分别'缩进'了八个字符,而第七行的 只'缩进'了一个字符,那么 到底是多少个字符呢(其实这个说法不对)?

         

      为了搞明白这个问题,测试的代码如下:

    1 print """
    2 12345678901234567890123456789012345678901
    3 	9	789	5		1
    4 1234567	9
    5 12345678	7
    6 """

        第二行的数字是为了方便计算字符数的参考,运行结果如下:

    12345678901234567890123456789012345678901
            9       789     5               1
    1234567 9
    12345678        7
    

      可以看到line3 的前三个  分别为八个、七个、五个字符,而 line4 line5 的为一个和八个字符

      其实到这里(虽然我还测试了一下其他的代码,但是我直接改成上面的代码了没保存,懒的再打了)可以大致猜测一下, 应该是八个字符为一个循环,每个  即代表当前八个字符的单元已经ok,然后进入下一串八个字符的单元

    所以line3 后面两个 应该分别缩进了七个和八个字符,这也可以解释之前代码中 为什么只'缩进'了一个字符。

      总结:

         其实代表当前八个字符的单元结束,进入到下一个八个字符的单元中。

  • 相关阅读:
    I/O会一直占用CPU吗?【转载】
    CPU和线程的关系
    future封装了callable,thread封装future。
    (转)Java中的守护线程
    线程中sleep方法和wait方法有什么区别?(转)
    Java异常---获取异常的堆栈信息
    分析iOS Crash文件,使用命令符号化iOS Crash文件
    String Matching(poj1580)
    U转串口驱动安装
    [LNU.Machine Learning.Question.1]梯度下降方法的一些理解
  • 原文地址:https://www.cnblogs.com/wenchaoz/p/5547804.html
Copyright © 2011-2022 走看看