Python之使用转义序列 \n 和 \t 跟 expandtabs 函数输出表格

 

示例:

text = "username\temail\tpassword\nashdfh\tfiodfh@q.com\ty567\nsdfiuh\tadfhisoj@163.com\t423678\nefuih\tosefih@q.com\t78\n"
v = text.expandtabs(20)
print(v)

# expandtabs 的作用是断句,在这里面的意思是每20个字符断一次,比如说text里面的 username\t 虽然username不够20个字符,但 \t 会把它没有占到的20个字符的位置上全部补成空格

输出如下

posted @ 2019-03-25 13:05  Jony-2018  阅读(622)  评论(0编辑  收藏  举报