Movatterモバイル変換
[0]ホーム
string->list->string
Courageousjkraska1 at san.rr.com
Mon Apr 23 21:35:38 EDT 2001
On Mon, 23 Apr 2001 18:36:48 -0600, Bjorn Pettersen <BPettersen at NAREX.com> wrote:>>>> x = [1,2,3]>>>> str(x)>'[1, 2, 3]'>>>> eval(str(x))>[1, 2, 3]Not getting it: I wants = "abc"l = list(s)<something>(l)"abc"Where something is some expression. The worst part here is that sometime inthe last year, I've asked this very same question before. *IRK* Is this in the FAQ?It outta be.>>>> s = "a!b%c^">>>> import string>>>> t = string.maketrans(s,s)>>>> s.translate(t, "!%^")>'abc'Hrm. I read the documentation for string.maketrans() and string.translate() just now.I don't get it. The documentation doesn't make this clear, and I don't understandfrom your example what's going on. While I can see that it works, I don't get thebasic principle. I would think a maketrans of s,s would just translate one characterto the same character.???C//
More information about the Python-listmailing list
[8]ページ先頭