[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: newbie question
From:       Matt Wheeler <m () funkyhat ! org>
Date:       2016-03-24 10:57:40
Message-ID: CAG93HwFywmkHdBMXMKOKCu7S6mHtvjZt5Lenzb8tG-aKigwm=Q () mail ! gmail ! com
[Download RAW message or body]

>>> import ast
>>> s = "(1, 2, 3, 4)"
>>> t = ast.literal_eval(s)
>>> t
(1, 2, 3, 4)

On 24 March 2016 at 10:39, ast <nomail@com.invalid> 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 ?
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Matt Wheeler
http://funkyh.at
-- 
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