Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带格式的python fstring_Python_Pandas_F String - Fatal编程技术网

带格式的python fstring

带格式的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

是否可以在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
02
10
20
03
04
30
40
01
02
10
20
03
04
30
40