字符串知识点
本帖最后由 温之夏梢 于 2021-4-10 15:21 编辑字符串内置函数expandtabs()和直接打印有什么区别,直接打印不也是吧'\t'转换为tab打印出来么,是不是只有改变空格参数的作用
str3 = 'I\tlove\tFishC.com'
print(str3)
print(str3.expandtabs()) 你们“老师” 都不教怎么查 官方文档 的吗?
IPython 7.17.0 -- An enhanced Interactive Python. Type '?' for help.
In : str.expandtabs?
Signature: str.expandtabs(self, /, tabsize=8)
Docstring:
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
Type: method_descriptor
In : 'ab\tcd\tef'.expandtabs()
Out: 'ab cd ef'
In : 'ab\tcd\tef'.expandtabs(2)
Out: 'abcdef'
In : 'ab\tcd\tef'.expandtabs(4)
Out: 'abcdef'
In : 'ab\tcd\tef'.expandtabs(8)
Out: 'ab cd ef'
In : 我觉得你看了这个后就明白了:
OK 我看写的挺不错的,关键的地方都标上了帮你 肖-肖 发表于 2021-4-10 17:56
我觉得你看了这个后就明白了:
这什么网站呀 肖-肖 发表于 2021-4-10 17:56
我觉得你看了这个后就明白了:
好的,谢谢
页:
[1]