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.
我有一个字符串str="[0,1,12]"
str="[0,1,12]"
去除 , 和唯一将数字留在后面的最有效"["方法"]"是","什么list?我试过.rstrip()了,但它只接受字符串末尾的字符。
"["
"]"
","
list
.rstrip()
将字符串计算为 a list:
from ast import literal_eval numbers = literal_eval(your_string)