如果我有一个由My.Function <- function(X1,X2,con.int) {
X1bar = sum(X1)/n
X2bar = sum(X2)/n
XD = X2-X1
XDbar = sum(X2-X1)/n
n = length(X1)
Sd = sqrt((sum((XD-XDbar)^2))/(n-1))
Alpha = 1 - con.int
T = qt(Alpha/2, n-1)
Lower.B = (X2bar - X1bar) - T*Sd/sqrt(n)
Uper.B = (X2bar - X1bar) + T*Sd/sqrt(n)
print(c(Lower.B,"X2bar - X1bar",Uper.B))
}
命令组成的列表:
dic.keys()
密钥由[
"['my', 'modem']", "['technical', 'schematics']", "['still', 'glad']",
"['spent', 'calling']", "['most', 'feared']", "['the', 'sysop']",
"['s', 'mystique']", "['had', 'been']", "['of', 'doom']",
"['i', 'hooked']", "['in', 'california']", "['my', 'ego']",
"['until', 'my']", "['didn', 't']"
]
组成,所以它看起来像list,但是是一个字符串。
我的问题是,你怎么能把每个项目分开来让它看起来像这样?
str()
答案 0 :(得分:0)
只需对每个字符串进行模式匹配:
res = []
for item in l:
m = re.match("\['(.*)', '(.*)'\]", item)
res.append(m.group(1))
res.append(m.group(2))
#>>> res - ['my', 'modem', 'technical', ...]