一、去除空格
strip()
1
2
3
4
|
" xyz " .strip() # returns "xyz" " xyz " .lstrip() # returns "xyz " " xyz " .rstrip() # returns " xyz" " x y z " .replace( ' ' , '') # returns "xyz" |
二、替换 replace("space","")
用replace("
", ""),
后边的串替换掉前边的
把str字符串转成字典(eval)
str = '{"token":"NjQtV3Q4RnpPQ0U=","license":"937ce8e8cbe97f0d58ea769aa045c75b"}'
print(str)
dic = eval(str)
print(dic)
print(type(dic))