string の、zfill を使う。
例
n = 3 n0 = str(n).zfill(10) print(n0)
結果
0000000003
雑記
投稿日:
string の、zfill を使う。
n = 3 n0 = str(n).zfill(10) print(n0)
0000000003
執筆者:seyanen
関連記事
c言語では、sprintf 関数を使って文字列を合成(連結)することができる。いっぽう、c++ では、文字列を string で表して「+」演算子で文字列を合成することができる。 例 #include …
テキストを \flushright で囲めば良い。 例 \begin{flushright} Lorem, ipsum dolor sit amet consectetur adipisicing e …
list に対して、extend を使う。 例 list1 = [1,2,3] list2 = [4,5,6] list1.extend(list2) print(list1) 結果 [1, 2, 3 …
plt.xlabel と plt.ylabel を使う。 例 import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, …
c++ で文字列(string)の foreach 操作を行う方法
string の各文字に対して操作を行うには、「iterator」(イテレータ)を使ってループを作る方法がある。iterator の変数名は、it としておくと分かりやすい。 例 #include&l …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。