带格式的python fstring
是否可以在fstring中添加if语句,如:带格式的python fstring,python,pandas,f-string,Python,Pandas,F String,是否可以在fstring中添加if语句,如: id1='somestring' for row,col in <some_condition>: col.to_excel(f'{id1}_concat(0,row[0])) id1='somestring' 对于行,列输入: col.to_excel(f'{id1}_concat(0,第[0]行))) 我想用零填充一位数的行[0],如果行[0]不是一位数,则不应用填充,谢谢 IIUC,您希望使用字符串格式 输出: 01 0
id1='somestring'
for row,col in <some_condition>:
col.to_excel(f'{id1}_concat(0,row[0]))
id1='somestring'
对于行,列输入:
col.to_excel(f'{id1}_concat(0,第[0]行)))
我想用零填充一位数的行[0],如果行[0]不是一位数,则不应用填充,谢谢 IIUC,您希望使用字符串格式 输出:
01
02
10
20
03
04
30
40
01
02
10
20
03
04
30
40