python - 如何使用python获取此字符串

标签 python string

我有一个这样的列表:

a=[1000,200,30]

我想得到这样的列表:

['01000','00200','00030']

那我该怎么办呢,

谢谢

最佳答案

>>> a=[1000,200,30]
>>> [str(e).zfill(5) for e in a]
['01000', '00200', '00030']

str.zfill

关于python - 如何使用python获取此字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5726134/

相关文章:

c# - WChar 与 Unicode 和 ASCII 有什么关系

string - 如何将 MATLAB 数组的所有元素合并为字符串?

python - 如何使用 SQLAlchemy/PostgreSQL 将日期+时间存储为 UTC

python - 使用 pandas 中 dataframe1 中某一列的值查找 dataframe2 中特定列的值

Java 字符串乘法

c++ - 与编译时未解析的字符串文字进行比较

string - 从常量 Ints 创建 Range<String.Index>

python - 连续的 ipywidgets 按钮

python - _portaudio.so : no matching architecture in universal wrapper

python - 从项目列表创建特定形状的 Pandas 数据框