Hi:
I have the folling code:
def parseTime(self, time):
minutes =int(float(time )/60)
seconds =int(float(time )-minutes*60)
minutes =str(minutes)
seconds =str(minutes)
the statements that convert the minutes and seconds variables
str(minutes) and str(seconds) don't seem to be working.
Any idea why?
is there any other way of doing this and perhaps using the $d
interpolation operator?
sean. 3 1663
Sean Farrow schrieb:
Hi:
I have the folling code:
def parseTime(self, time):
minutes =int(float(time )/60)
seconds =int(float(time )-minutes*60)
minutes =str(minutes)
seconds =str(minutes)
the statements that convert the minutes and seconds variables
str(minutes) and str(seconds) don't seem to be working.
Any idea why?
is there any other way of doing this and perhaps using the $d
interpolation operator?
What do you mean by "don't seem to be working"
Usually, they do:
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit <tabmultiple times
>>str(120)
'120'
>>>
Any change you overdefined str with something weird?
Diez
On Jun 8, 10:40 am, Sean Farrow <sean.far...@se anfarrow.co.ukw rote:
Hi:
I have the folling code:
def parseTime(self, time):
minutes =int(float(time )/60)
seconds =int(float(time )-minutes*60)
minutes =str(minutes)
seconds =str(minutes)
the statements that convert the minutes and seconds variables
str(minutes) and str(seconds) don't seem to be working.
Any idea why?
is there any other way of doing this and perhaps using the $d
interpolation operator?
sean.
The divmod builtin function is your friend here.
def parseTime(time) :
seconds = float(time)
minutes,seconds = divmod(seconds, 60)
return "%02d:%06.3 f" % (minutes,second s) # just guessing
divmod divides the first argument by the second, and returns the tuple
(quotient,remai nder).
-- Paul
On Jun 9, 1:40 am, Sean Farrow <sean.far...@se anfarrow.co.ukw rote:
Hi:
I have the folling code:
def parseTime(self, time):
minutes =int(float(time )/60)
seconds =int(float(time )-minutes*60)
minutes =str(minutes)
seconds =str(minutes)
seconds = str(minutes) ???
Is that the actual code that you executed?
What does "don't seem to be working" mean? The seconds output is
always the same as the minutes output?
Try again, with
seconds = str(seconds)
followed by
print "debugging" , repr(time), repr(minutes), repr(seconds)
If it still seems not to be working, come back with a copy/paste of
the actual code that you executed, plus a copy/paste of the output
the statements that convert the minutes and seconds variables
str(minutes) and str(seconds) don't seem to be working.
Any idea why?
is there any other way of doing this and perhaps using the $d
interpolation operator?
What is the $d interpolation operator? Do you mean the %d string
formatting operator? If so, the answer depends on what you want to do
with the output ... e.g.
"%d:%02d" % (int_minutes, int_seconds)
might be what you want. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Cyde Weys |
last post by:
I'm currently working on converting a simulator program from Visual
Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but
there's still one thing I haven't gotten to and I've never really had
to deal with it before. I'm programming a front-end for what is a
compiled Fortran program. The VB source does the following to call
the Fortran:
'Defines the subroutine.
Declare Sub Cycle_DW Lib "cycdw.dll" Alias "CYCDW" (ByRef...
|
by: Edward Diener |
last post by:
I received no answers about this the first time I posted, so I will try
again. My inability to decipher an MSDN topic may find others who have the
same inability and someone who can decipher and explain it.
I have some questions about the instructions for creating a mixed mode DLL
in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure
Intermediate Language to Mixed Mode" in the "Managed Extensions for C++
Reference"....
|
by: Paraic Gallagher |
last post by:
Hi,
This is my first post to the list, I hope somebody can help me with this
problem. Apologies if it has been posted before but I have been internet
searching to no avail.
What I am trying to do is provide a simple method for a user to change a
config file, for a test suite.
The config file consists of a number of keys, eg. build number, target
device, etc.
|
by: Wallace |
last post by:
Hai,
Can anyone tell how to convert an object into string?
Please help me.... urgent..
Thanx in advance...
|
by: gg9h0st |
last post by:
i'm a newbie studying php.
i was into array part on tutorial and it says
i'll get an array having keys that from member variable's name
by converting an object to array.
i guessed "i can get public members but not protected, private, static
members"
| |
by: Terry |
last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces.
One of the major uses is to be able to split out Read-only access to an
obect. Let me give you a simple (contrived) example:
In Project RoObjDefs:
RoPerson.cls file:
Public Property Get FirstName() as String
Public Property Get LastName() as String
<end of file RoPerson.cls>
RoPersons.cls file
Public Function Count() as Integer
|
by: SMichal |
last post by:
Hi, how can I parse string "? 20.000" to double ?
|
by: nvx |
last post by:
Hi,
I'm looking for a simple way to convert a Double to a String exactly
the .ToString() does, except these two differences:
- the number of decimals is given (rounding is applied if
necessary), and
- trailing zeroes are kept.
This means I need it to be converted using the scientific notation if
the number is greater than a certain value etc., not just a simple
"this number of digits (or more if needed) before the decimal point
|
by: CoreyWhite |
last post by:
Problem:
You have numbers in string format, but you need to convert them to a
numeric type, such as an int or float.
Solution:
You can do this with the standard library functions. The functions
strtol, strtod, and strtoul, defined in <cstdlib>, convert a null-
terminated character string to a long int, double, or unsigned long.
You can use them to convert numeric strings of any base to a numeric
|
by: Hank Stalica |
last post by:
I'm having this weird problem where my code does the following
conversion from string to float:
27000000.0 -27000000.00
2973999.99 -29740000.00
2989999.13 -2989999.25
The number on the left is the string I get after tokenizing a bigger
string. The number on the right is the number I get after the conversion.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |