未分類

python3 で、文字列のパーセント(%)をそのまま表示する方法

投稿日:

文字列の始まりに r をつけて、raw 文字列にするとパーセントなどの文字をそのまま表示できる。

str1 = r'%s%d\t'
print(str1)

結果

%s%d\t

-未分類

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

matplotlib で x軸・y軸ラベルをつける

plt.xlabel と plt.ylabel を使う。 例 import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, …

no image

python3 で、ファイルの文字列の1行目を出力する

ファイルを読み込んで、1行目だけをコンソールに出力するには readlines() を使う。 例 f = open(“data.txt”) lines = f.readlines() print(li …

no image

tex で和集合を入力する方法

\bigcup を使う。 例 $\displaystyle \bigcup _ {i \in \Lambda} A_i $ 結果

no image

tex で差集合の記号を入力する方法

\setminus を使う。 例 $A \setminus B$ 結果

no image

tex で期待値記号を入力する方法

\mathbf を使う。 例 $\mathbf{E}(\xi)$ 結果