大佬们求助,小白一枚。。。。关于小甲鱼第14课的一个小问题
expandtabs函数如何他的tabsize指定为2,怎么不一样的。。。>>> str = "this is\tstring example....wow!!!";
>>>print "Original string: " + str
>>>print "Defualt exapanded tab: " +str.expandtabs()
>>>print "Double exapanded tab: " +str.expandtabs(2)
Original string: this is string example....wow!!!
Defualt exapanded tab: this is string example....wow!!!
Defualt exapanded tab: this is string example....wow!!!
不太懂
我懂tabsize(8)和tabsize(16)
但为什么tabsize(2)会不一样
我都不会数了 建议用Python3 你还在用Python2!? 我用Python3的 永恒的蓝色梦想 发表于 2020-4-14 21:43
建议用Python3
我就是用的Python3,Python3.8.2 wuqramy 发表于 2020-4-14 21:58
你还在用Python2!?
我就是用Python3,Python3.8.2 牛逼牛逼 发表于 2020-4-14 22:01
我就是用Python3,Python3.8.2
你的语法就是Python2的 牛逼牛逼 发表于 2020-4-14 22:01
我就是用Python3,Python3.8.2
Python 3.8.2 print 不加括号? wuqramy 发表于 2020-4-14 22:05
你的语法就是Python2的
>>> str3 = 'I\tlove\tFishC.com'
>>> str3.expandtabs(2)
'I loveFishC.com'
这个呢为什么love后面两个空格,从love开始数起已经四个数了,我要求是2个,实在看不懂 tabsize 的默认值为8。tabsize值为0到7等效于tabsize=8。tabsize每增加1,原字符串中“\t”的空间会多加一个空格,我上网搜的,我已经清楚了。大佬们这是对的吗
页:
[1]