我目前正在使用 f-string 在雙引號周圍打印一些值:f.write(f'"{str(ID).rstrip("'")}", "{str(TSQ)}" \n')問題是由于"'"rstrip 參數,我收到了SyntaxError: unexpected character after line continuation character我知道有一些簡單的修復方法可用,例如預先使用.format()或對字符串進行處理ID,但由于使用 f-strings 通常更像 pythonic,我想知道是否有解決方法。如果 ID 為 872' 且 TSQ 為 8,則此代碼應打?。?quot;872", "8"
添加回答
舉報
0/150
提交
取消