Could not insert Dict format inside f string

Could not insert Dict format inside f string

in_folder=r"C:\Test"
name={
    "OK":r"OK.csv",
    "NG":r"NG.csv",
}
#NG
print(f"{in_folder}\{name["NG"]}"))#Syntax error
print(f"{in_folder}\{name[`NG`]}"))#Syntax error

#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"

The string may be useless

Recommended Posts

Could not insert Dict format inside f string
String format
String format 2
Insert an object inside a string in Python
Python string format
Python string format