1
0

More than 3 years have passed since last update.

f文字列内部にDict形式を挿入できなかった

Posted at

f文字列内部にDict形式を挿入できなかった

in_folder=r"C:\Test"
name={
    "OK":r"OK.csv",
    "NG":r"NG.csv",
}
#NG
print(f"{in_folder}\{name["NG"]}"))#シンタックスエラー
print(f"{in_folder}\{name[`NG`]}"))#シンタックスエラー

#OK
OK_file="OK"
print(f"{in_folder}\{name[OK_file]}"))#"C:\Test\OK.csv"
print("{}\{}".format(in_folder,name["OK"]))#"C:\Test\OK.csv"

文字列はだめだったりするのかもしれない

1
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0