formatting

How get hours:minutes

白昼怎懂夜的黑 提交于 2019-12-30 18:44:09
问题 I have a script here (not my own) which calculates the length of a movie in my satreceiver. It displays the length in minutes:seconds I want to have that in hours:minutes What changes do I have to make? This is the peace of script concerned: if len > 0: len = "%d:%02d" % (len / 60, len % 60) else: len = "" res = [ None ] I already got the hours by dividing by 3600 instead of 60 but can't get the minutes... Thanks in advance Peter 回答1: You can use timedelta from datetime import timedelta str

NetBeans saves code incorrectly (all on one line with squares where the line breaks should be)

痞子三分冷 提交于 2019-12-30 13:54:48
问题 Issue 1 I have been using NetBeans on my work machine to develop a PHP website. The issue I have is that using netbeans, in the application itself, every other line is a blank line. Even opening a correctly formatted document will cause this issue. E.g.: Coded using Notepad: <p> Test para with just a standard line break and just a few more to show what I mean </p> When displayed in NetBeans is shows as: <p> Test para with just a standard line break and just a few more to show what I mean </p>

C# - Excel Number Formatting Issue with International settings

戏子无情 提交于 2019-12-30 11:13:47
问题 I am trying to write to an Excel 2003 spreadsheet using c# 3.5. However I am unable to get this to function correctly across different country settings. The country settings are either English or German. These two settings have different decimal and thousands settings. Everything works fine unless a user has changed the decimal and thousands separators in the International settings of the Options screen. Can anybody help as I feel I can no longer see the wood for the trees and am missing

Telephone number format should be international,Is there any Regex for phone number validation in iPhone

我是研究僧i 提交于 2019-12-30 07:50:06
问题 Telephone number should be international and user has to enter the complete phone number with country code. For that I need a regex for formatting the phone number. 回答1: For real regex testing use RegexKitLite. As for the regular expression itself, something like this (from Validate Phone Numbers: A Detailed Guide) should work: ^\+(?:[0-9] ?){6,14}[0-9]$ Note that when you specify it in your code you need to escape the backslash character (\), so it would look like this: NSString *regexString

Telephone number format should be international,Is there any Regex for phone number validation in iPhone

爱⌒轻易说出口 提交于 2019-12-30 07:50:06
问题 Telephone number should be international and user has to enter the complete phone number with country code. For that I need a regex for formatting the phone number. 回答1: For real regex testing use RegexKitLite. As for the regular expression itself, something like this (from Validate Phone Numbers: A Detailed Guide) should work: ^\+(?:[0-9] ?){6,14}[0-9]$ Note that when you specify it in your code you need to escape the backslash character (\), so it would look like this: NSString *regexString

python logging string formatting

六眼飞鱼酱① 提交于 2019-12-30 06:06:28
问题 I am using python's log formatter to format log records and i have a fmt value of fmt = "[%(filename)s:%(lineno)s] %(message)s" What i would like is that "[file.py:20]" to be stretched to 10 characters wide (for example). If it was one value that would have been easy but is there any way to stretch this entire structure to a specified length? I want something like: tmp = "[%(filename)s:%(lineno)s]" fmt = "%(tmp)10s %(message)s" I would like to know if this is possible using string formatting

python logging string formatting

跟風遠走 提交于 2019-12-30 06:05:10
问题 I am using python's log formatter to format log records and i have a fmt value of fmt = "[%(filename)s:%(lineno)s] %(message)s" What i would like is that "[file.py:20]" to be stretched to 10 characters wide (for example). If it was one value that would have been easy but is there any way to stretch this entire structure to a specified length? I want something like: tmp = "[%(filename)s:%(lineno)s]" fmt = "%(tmp)10s %(message)s" I would like to know if this is possible using string formatting

Using -f operator on a string that contains curly braces

萝らか妹 提交于 2019-12-30 05:56:35
问题 Consider the following here-string that I am trying to use a template for my Nagios definitions. $blankDefinition = @" define host{ use windows-server ; Inherit default values from a template host_name {0} ; The name we're giving to this host alias {0} ; A longer name associated with the host address {1} ; IP address of the host } "@ I have a script that determines which of my servers are not in nagois that should be. As it loops I'm trying to have it spit out a definion for me so that I can

Consolidate stacked DOM formatting elements - contenteditable DIV

≡放荡痞女 提交于 2019-12-30 05:27:12
问题 I have a contenteditable DIV which is linked/synced-back to a textarea. The contenteditable DIV is a free-for-all sandbox which will create formatting elements etc as they are being invoked. However this does result often in messy stacked elements. I would like to be able to clean up the code before the textarea form is sent to the server. It is possible to end up with something like the following: <div> <b> <i> Hel </i> <i> l </i> </b> <i> <b> o World! </b> </i> </div> Which would ideally be

How to change Phone number format in input as you type?

妖精的绣舞 提交于 2019-12-29 14:18:13
问题 My CodePen: http://codepen.io/leongaban/pen/cyaAL I have an input field for a phone number which allows up to 20 characters (for international numbers). I'm also using the Masked input jQuery plugin by Josh Bush to format the phone number in the input to make it 'pretty'. My problem is that in the requirements when the phone is 10 digits or less, it should use the Masked input formatting. However when the phone number is longer then 10 digits, the formatting should be removed. Here is my