未分類

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

投稿日:

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

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

結果

%s%d\t

-未分類

執筆者:


comment

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

関連記事

no image

c++ で文字列(string)の長さを取得する方法

length() で取得する。 例 #include <iostream> #include <string> using namespace std; int main () { str …

no image

c++ で文字列を「区切り文字」を使って分ける方法

string の find を使って、区切り文字の場所を取得し、その位置で区切る。 例 #include <iostream> #include <string> using namesp …

no image

matplotlib で x, y軸・タイトルのフォントサイズを調整する

ラベルの fontsize で指定する。 例 import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2, 100) …

no image

tex と分数

tex で分数を入力するには、frac を使います。 \frac{2}{3} 表示結果 次のように表示されてしまう場合は、バッククォート(\ マーク)が抜けているのが原因です。 間違った場合。

no image

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

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