我有python函数:
def myFunction(inputList):
outputList = ['Path | Type | Size']
for item in inputList:
outputList.append(item + ' | ' + parseFileType(item) + ' | ' + parseFileSize(item))
return outputList
这个函数有如下输出:
Path | Type | Size
/etc/acpi | directory | 16 Kb.
/etc/adduser.conf | ASCII text | 4,0 Kb.
/bin/df | ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=8b0d9cd8d2256a94b9ea7e2248b6d8721cff588d, stripped | 84 Kb.
如何对此函数的文本输出设置自动宽度,因为它看起来像:
Path | Type | Size
/etc/acpi | directory | 16 Kb.
/etc/adduser.conf | ASCII text | 4,0 Kb.
...
您可以尝试这样做,以确保每个字符串都具有相同的长度,这将保证您的列看起来像您希望的那样
相关问题 更多 >
编程相关推荐