I am currently attempting to work on converting a fairly sizeable JSON object
and convert it into a CSV format. However, when I attempt to do so, using a
conventional approach (that seems to work with other files). I am presented
with a "ValueError: too many values to unpack"
I have tried to fl
August 12, 2008 11:27 AM
To: python-list@python.org
Subject: Unable to lookup keys in dictionary
I am trying to run p4python API on top of python 2.5.2 and am extracting
a dictionary from perforce. The following code returns the output that
follows it:
from P4 import P4, P4Exception
On Tue, Aug 12, 2008 at 11:27 AM, Matt Fielding (R* New England)
<[EMAIL PROTECTED]> wrote:
> [{'userName': 'mfielding', 'clientRoot': 'c:\\perforce', 'monitor':
> 'enabled',
> 'serverRoot': 'H:\\p4root\\', 'serverVersion': 'P4D/NTX64/2007.3/143793
> (2008/01/
> 21)', 'serverDate': '2008/08/12 11:1
>I am trying to run p4python API on top of python 2.5.2 and am
extracting a dictionary from perforce. The following code returns the
output that follows it:
>
> from P4 import P4, P4Exception
> p4 = P4()
> p4.port = "erased" #deleted
> p4.us
I am trying to run p4python API on top of python 2.5.2 and am extracting
a dictionary from perforce. The following code returns the output that
follows it:
from P4 import P4, P4Exception
p4 = P4()
p4.port = "erased" #deleted
p4.user = "erased" #deleted
use (1,2) , (3,4)
"Shi Mu" <[EMAIL PROTECTED]> a écrit dans le message de news:
[EMAIL PROTECTED]
I run the following code and got wrong message, but I still want to
make [1,2],[4,3] and [6,9]
to be keys of the dictionary or change the style a little bit. How to do
that?
Thanks!
>>> p=[[1,
Shi Mu wrote:
> I run the following code and got wrong message, but I still want to
> make [1,2],[4,3] and [6,9] to be keys of the dictionary or change the
> style a little bit. How to do that?
Make them tuples:
>>> p=[[1,2],[4,3],[6,9]]
>>> n=dict([(tuple(x),[]) for x in p])
>>> n
{(6, 9): [
I run the following code and got wrong message, but I still want to
make [1,2],[4,3] and [6,9]
to be keys of the dictionary or change the style a little bit. How to do that?
Thanks!
>>> p=[[1,2],[4,3],[6,9]]
>>> n=dict([(x,[]) for x in p])
Traceback (most recent call last):
File "", line 1, in ?
On Fri, Feb 18, 2005 at 09:35:30AM +0100, Thomas Guettler wrote:
> Am Thu, 17 Feb 2005 18:13:46 -0800 schrieb neutrinman:
>
> > Hi,there. How can I choose a key in dictionary randomly?
> >
> > Say, random.choice() in lists,
> >
> > or in lists:
> > lists = [1,2,3,4]
> > position = random.range(l
Am Thu, 17 Feb 2005 18:13:46 -0800 schrieb neutrinman:
> Hi,there. How can I choose a key in dictionary randomly?
>
> Say, random.choice() in lists,
>
> or in lists:
> lists = [1,2,3,4]
> position = random.range(len(lists))
> word = lists[position]
Hi, try this:
import random
mydict={1: "one"
> Hi,there. How can I choose a key in dictionary randomly?
>
> Say, random.choice() in lists,
A dictionary's keys() are a list, so you already have the answer:
>>> import random
>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> random.choice(d.keys())
=Tony.Meyer
--
http://mail.python.org/mailman/listinfo
Hi,there. How can I choose a key in dictionary randomly?
Say, random.choice() in lists,
or in lists:
lists = [1,2,3,4]
position = random.range(len(lists))
word = lists[position]
--
http://mail.python.org/mailman/listinfo/python-list
12 matches
Mail list logo