ToString[i]}]; Print[f1]; , -6ren">
gpt4 book ai didi

wolfram-mathematica - 如何在Mathematica中打印以n个前导零开头的整数?

转载 作者:行者123 更新时间:2023-12-04 02:56:52 26 4
gpt4 key购买 nike

我尝试执行以下操作:

Do[
f1 = StringReplace[
"obsxxxx.out", {"xxxx" -> ToString[i]}];
Print[f1];
,
{i, 200}];

并获得
obs0001.out
obs0002.out
...
obs0010.out
...
obs0100.out
...

等等。

我尝试过:
ToString[Flatten[IntegerDigits[20, 10, 4]]]

但我还有一个 list ...

最佳答案

也许您需要类似以下内容:

Table[IntegerString[i, 10, 4], {i, 1, 10}]

给予
{"0001", "0002", "0003", "0004", "0005", "0006", "0007", "0008", 
"0009", "0010"}

或者
Table["obs" <> IntegerString[i, 10, 4] <> ".out", {i, 1, 10}]

给予

{"obs0001.out", "obs0002.out", "obs0003.out", "obs0004.out", "obs0005.out", "obs0006.out", "obs0007.out", "obs0008.out", "obs0009.out", "obs0010.out"}

关于wolfram-mathematica - 如何在Mathematica中打印以n个前导零开头的整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7419245/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com