Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在已经包含两者的 JSON 文件中将任何更改None为(注意单引号)。'None'
None
'None'
type: None or type: 'None'
我试过"s/[']?None[']?/'None'/g"了,但它似乎不起作用。
"s/[']?None[']?/'None'/g"
既然您将 all 更改None为,那么仅使用该 json 字符串'None'会不会更容易?str.replace我会在两个过程中运行它,首先更改'None'为None,然后将所有更改None为'None'。
str.replace
s/([^'])?(None)([^'])?/$1'$2'$3/g