[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: newbie question
From: Steven D'Aprano <steve () pearwood ! info>
Date: 2016-03-24 11:13:20
Message-ID: 56f3cbd2$0$1609$c3e8da3$5496439d () news ! astraweb ! com
[Download RAW message or body]
On Thu, 24 Mar 2016 09:39 pm, ast wrote:
> Hi
>
> I have a string which contains a tupe, eg:
>
> s = "(1, 2, 3, 4)"
>
> and I want to recover the tuple in a variable t
>
> t = (1, 2, 3, 4)
>
> how would you do ?
py> import ast
py> ast.literal_eval("(1, 2, 3, 4)")
(1, 2, 3, 4)
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic