given a string:
msg="hello world"
How can I define this as a ctypes.c_void_p() data type?
the following code yields a "cannot be converted to pointer" exception:
data=ctypes.c_void_p(msg)
data is required to be a void* type in ... |
I'm using Python 2.5. The DLL I imported is created using the CLR.
The DLL function is returning a string. I'm trying to apply "partition" attribute to it. I'm not able to ... |
I want to convert strings to bit-fields.Also,convert them to binary and then use.
Need help with this..help me ..
|
I'm new to python, and have a list of longs which I want to join together into a comma separated string.
In PHP I'd do something like this:
$output = implode(",", $array)
In Python, ... |
I would like to know how to convert a string containing digits to a double.
|
Does anyone know how to do convert from a string to a boolean in Python? I found this link. But it doesn't look like a proper way to do ... |
More specific dupe of 875228—Simple data storing in Python.
I have a rather large dict (6 GB) and I need to do some processing on it. I'm trying out several ... |
|
How do I do the following in Python 2.2 using built-in modules only?
I have a list of lists like this:
[['dog', 1], ['cat', 2, 'a'], ['rat', 3, 4], ['bat', 5]]
And from ... |
I try logging exceptions in Python 2.5, but I can't do it. All formatting functions do something else than what I want.
I came up with this:
def logexception(type, value, traceback):
print ...
|
How can I convert a list of strings (each of which represents a number, i.e. [‘1’, ‘2’, ‘3’]) into numeric values.
|
There is a read-only library function that takes a file as an argument.
But I have a string.
How do I convert a string to a file, that if you read the file ... |
I have a python list variable that contains strings. Is there a python function that can convert all the strings in one pass to lowercase and vice versa, uppercase?
Regards
|
In Python I have four strings that include the formatting of a list:
line1 ="['a.b.c','b.c.a','c.d.e']"
line2 ="['def','efg']"
line3 ="['f']"
line4 ="['g']"
How do I merge them all so I get a valid Python list such as:
SumLine ...
|
s='This is sample'
i need to convert like this
s='"This is sample"'
output= "This is sample"
how to do this in dynamic
Thanks in advance
|
I was wondering what the simplest way to convert a string list like
x =u'[ "A","B","C" , " D"]'
... |
I want to check whether the given string is single- or double-quoted. If it is single quote I want to convert it to be double quote, else it has to be ... |
I would like my code to look beautiful
Thanks in advance..
|
I'm using appengine to develop an application. Ideally I would like to define a new kind (called Recipe) like this:
class Recipe(db.Model):
ingredients = db.ListProperty(type)
quantities ...
|
I am using dbus to get the current playing song from Songbird Media Player & Metadata is also taken from dbus object.
The line where error comes is:-
audio_file = MP3(current_playing_track['location'], ID3=ID3)
The error ... |
How can I convert this so it could execute?
Traceback (most recent call last):
File "C:\Users\Shady\Desktop\tet.py", line 14, in <module>
exec test
File "<string>", line 1
...
|
I have a text document that contains a list of numbers and I want to convert it to a list. Right now I can only get the entire list in the ... |
How do I convert this:
[True, True, False, True, True, False, True]
Into this:
'AB DE G'
Note: C and F are missing in the output because the corresponding items in the input list are ... |
I have extracted some data from the file and want to write it in the file 2 but the program says 'sequence item 1: expected string, list found', I want ... |
The original question was:
Is there a way to declare macros in Python as they are declared in C:
#define OBJWITHSIZE(_x) (sizeof _x)/(sizeof _x[0])
Here's what I'm trying to find out:
Is there a way ... |
String(Math.round(values/30))..am having values 65.i want the answer for that 3 not 2.1...
wat is the solution
|
How can i convert this input into a string?
GET /learn/tutorials/351079-weekend-project-secure-your-system-with-port-knocking?name=MyName&married=not+single&male=yes HTTP/1.1
Host: merch1.localhost
User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11
Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
I NEED THIS AS OUTPUT
GET /learn/tutorials/351079-weekend-project-secure-your-system-with-port-knocking?name=MyName&married=not+single&male=yes HTTP/1.1 Host: merch1.localhost ... |
I'm converting color values to string values, however when I get 0, the string is too short and I have to manually add "00" after it.
Whats the most elegant way to ... |
I’ve got a long string object which has been formatted like this
myString = “[name = john, family = candy, age = 72],[ name = jeff, family = Thomson, age = 24]”
of ... |
I've written a function in python that returns a list, for example
[(1,1),(2,2),(3,3)] etc
But i want the output as a string so i can replace the comma with another char so the ... |
How to convert string to list
str = '[(testing1@testing.com, amit, laspal,1,100,50),
(testing2@testing.com,None,None,None,None,None),
(testing3@testing.com,laspal, amit,None,None,None)]'
I want ... |
I am writing a program that stores data in a dictionary object, but this data needs to be saved at some point during the program execution and loaded back into the ... |
Python provides a convenient method long() to convert string to long:
long('234')
; converts '234' into a long
If user keys in 234.89 then python will raise an error message:
ValueError: invalid literal for ...
|
I'm using libxml2 and libxslt to process XML files. The return value is of type instance but I need to have a UTF-8 static string.
styledoc = libxml2.parseFile(style_file)
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseDoc(xml_data.encode("UTF-8")) ...
|
I am using the date time lib to get the current date. After obtaining the current date I need to convert the obtained date to in to a string format. Any ... |
How do i convert
'[update, /CoaddedRegriddedFrame[1]/OBJECT[1]/text()[1], Centaurus-AB]'
to a list of strings, eg.
['update', '/CoaddedRegriddedFrame[1]/OBJECT[1]/text()[1]', 'Centaurus-AB']
|
I have string in the form
[3339:1.6101369,1062:1.5,5751:1.5,6376:1.5, ... ]
I want to iterate through the comma separated key-value pairs. What is the best or shortest way to do this?
|
Possible Duplicate:
How to convert list into a string?
Hi there,
How to convet list to an string.
thanks
|
Possible Duplicate:
Converting a string that represents a list, into an actual list object.
hi,
i have a string in this format:
>>> x="(174,185)"
>>> x
'(174,185)'
how can i convert ... |
Im trying to incorporate my encryption program into a chat program. But i cant pass a MutableString with Socket. So how would I properly covert my MutableString into a proper string?
import ...
|
What's a simple way to convert stings into numerics:
from:
['3.65e+03', '1.14e+04', '1.35e+04', '1.46e+04']
to:
[3.65e+03, 1.14e+04, 1.35e+04, 1.46e+04]
Thanks.
|
Given a Python string like this:
location_in = 'London, Greater London, England, United Kingdom'
I would like to convert it into a list like this:
location_out = ['London, Greater London, England, United Kingdom',
...
|
I have a script, which take input from the user and I want to validate the input first then convert the user-input to a predefined format. The input should be like ... |
In Python, the following code produces an error:
a = 'abc'
b = 1
print(a + b)
(The error is "TypeError: cannot concatenate 'str' and 'int' objects").
Why does the Python interpreter not automatically try using ... |
Basically I have the inverse of this problem: Python Time Seconds to h:m:s
I have a string in the format H:MM:SS (always 2 digits for minutes and seconds), and I need ... |
I would like to be able to convert a string such as "1,2,5-7,10" to a python list such as [1,2,5,6,7,10]. I looked around and found this, but I was wondering ... |
Is there any way to convert an entire user inputed string from uppercase, or even part uppercase to lowercase. eg. Kilometers --> kilometers. I am writing a program that doesn'st work ... |
In netaddr module there are functions that convert either an ip range (iprange_to_globs(start, end)), or a CIDR (cidr_to_glob(cidr)) to a glob. A glob is a "user friendly form ... |
I need this because I am using AJAX to transfer a file, hence I get an image file in a base64 encoded string. I would like to convert this nicely to ... |
In my application I have generated a number of values (three columns, of type int, str and datetime, see example below) and these values are stored in a flat file as ... |
lets say i have :
my_args = ["QA-65"]
as the desired result
but in my function, i have:
m = re.search("([a-zA-Z]+-\d+)",line)
... |
I have a string:
x = "12.000"
And I want it to convert it to digits. However, I have used int, float, and others but I only get 12.0 and i want to ... |
I need help for my homework. First I need to ask for a list from a user then I
need to convert it to string. Then program ask another list for converting. ... |
Possible Duplicate:
String to list in Python
i have a string like this :
states = "Alaska Alabama Arkansas American Samoa Arizona California Colorado"
and I ... |
|
|
|
|
what if your variable "s" was 10, such that s is always one digit less than from the lists inside the list of lists. because i entered s as 10 and my "data" was at [[0, 1, 0], [0, 1, 0], [1, 1, 0]] but it said 'Variable is not in the list.' but "10" is found from within all of ... |
|
Code: Select all import re regex = r''' (?P\d+)-(?P\w+)-(?P\d+)\s # dd-sss-dd (?P\d+):(?P\d+):(?P\d+)\s # dd:dd:dd (?PAM|PM)''' ... |
|
|
Hi, I'm working on an alarmclock program, that will interface with spotify to make me up every morning with some sweet, sweet reggae. The first problem I encountered is how to make a valid timestamp that python can understand, from a string. The program will ask "What time do you want to wake up?" And I'll enter something like "7:45" How ... |
Hi, I have a list that I need to insert into a sqlite database. I am new to Python so I don't have working with list down yet. I have this list. [u'Andy Jay Powell', [u'A. J. Powell', u'A.J. Powell', u'A.J.P.', u'AJP', u'Andy J Powell', u'Andy J. Powell', u'Andy Jay Powellv', u'Andy Powell'], [u'http://www.andyjaypowell.de/', u'http://www.myspace.com/andyjaypowell'], [u'25 Style', u'Andreas Paul', u'Antonio Baresi', ... |
|
I know in Python 2.7 that you could convert from a string to a list of characters by calling the list() function with your string that you wanted converted. This does not seem to work anymore in Python 3.1 It returns TypeError: 'list' object is not callable. Anyone have any idea if there is some other way of doing this is ... |
Dear All, I want to output the processed data onto a file the output data is a JSON format converted from a csv file. The program runs fine the Print command prints the output on the screen however i want to output onto a file to use it with some other application. The string conversion doesn't work, probably because the syntax ... |
|
|
|
|
I have a program (It is still in brainstorming mode, so there isn't actually any real code.) that requires a conversion of a string into Python code. Pretty much, here's the dilemma: I have twenty-six variables, a through z, or if you prefer, a1-26. Depending on user input, I have to put a number into different variables, and I don't want ... |
avisser has a good point -- if the string is coming from inside your program, it would be a lot easier just to pass True and False directly instead of "True" and "False". If the string is user input, however, then the "if" statement you described is probably the best way to go. |
|
@HenriAB: How would using eval() be different from using int()? Also, I though eval() was supposed to be one of those things you should very rarely (if ever) use, like input()? @Bill: Yes, if it was stored as a string, then str() shouldn't be very memory intensive at all, right? Actually, doing everything with strings does seem easier here. Thanks for ... |
|
Code: Select all for track in LiveUtils.getTracks(): for clipSlot in track.clip_slots: if clipSlot: ... |
There is probably a much better way to do this Code: Select all def str_dict(string): dict={} for pair in string.split(','): key_val=pair.split(':') print key_val ... |
def SetOption(self, *args): print args print "args[0] = %s"%(args[0]) print "pycurl.URL = %i"%(pycurl.URL) print "self.pycurlobj.URL = %i"%(self.pycurlobj.URL) print "pycurl.args[0] = pycurl.%s"%(args[0]) print ... |
Python 2.4.3 (#2, Oct 6 2006, 07:52:30) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> foo = '[1,2,3]' >>> [int(x) for x in foo] Traceback (most recent call last): File "", line 1, in ? ValueError: invalid literal for int(): [ >>> map(int.foo) Traceback (most recent call last): ... |
|
|
Hello, Well, let's see. I'd loop over the keys of the dictionary, and then access the list of lists using myDict[myKey]. Then you'll need to iterate over the sublists. Then you'll need to iterate over the indices of the sublists and for each index reset the value of the corresponding sublist at the same index to the "upper case" version of ... |