我有一個元組,我想字符串化,使之成爲一個Redis的關鍵。字符串化Python中的元組與破折號
我已經試過「 - 」加入,但輸出並不好 - >從字符串的每一個字母之間的連字符。任何人都可以建議比我的字符串更好的功能+' - '+ string2 ...下面的建設?
謝謝!
matchkey = (mdate, season, aseries, homeclub, awayclub, court)
mk = mdate + '-' + season + '-' aseries + '-' homeclub + '-' awayclub + '-' court
,你在幹什麼' '_'。加入(mdate +季節+ A系列+ homeclub + awayclub +法院)'讓 「_」 每個字母或別的東西之間? –
條款之間想要破折號,而不是在每個字母之間。對於未來的stringifiers,這裏就是發生在你STR()元組,然後嘗試加入破折號:>>> MK1 = STR(matchkey) >>> MK2 = ' - ' 連接(MK1) >>>打印MK2。 (-'-2-0-1-1 --- 0-1 --- 0-5 -'-, - -2-2 - , - □ - Winter- -Club-1, - - - ' -Knollwood-', - 2) –
ahh。我懂了。你只是按照錯誤的順序來做 –