這裏是Python中的字符串:Python函數的參數和文件混亂
a = "asdf as df adsf as df asdf asd f"
比方說,我想 「與 」||「 全部替換」,所以我做的:
>>> a.replace(" ", "||")
'asdf||as||df||adsf||as||df||asdf||asd||f'
我的困惑是the documentation如下信息:
string.replace(s, old, new[, maxreplace])
Return a copy of string s with all occurrences...
我可以「忽略」 s
,但是基於實況我需要s
;但是,我只提供old
和new
。我注意到它是這樣的,有很多python文檔;我錯過了什麼?
它是'str',而不是'string'。 –