format

String formatting error

为君一笑 提交于 2019-12-24 07:35:38
问题 Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error: AttributeError: 'str' object has no attribute 'format' when I delete the line Netbeans automatically inserted at the beginning: from distutils.command.bdist_dumb import format which itself causes an error of ImportError: cannot import name format What am I doing wrong here? 回答1: You must be running an older version of Python. This does work in Python 3.1.1+: $ python3 Python 3.1.1+ (r311

Can I use the .format feature when using screen.blit in Pygame?

*爱你&永不变心* 提交于 2019-12-24 07:19:49
问题 Heys, I recently couldnt figure out how to blit lists onto my pygame screen using certain x and y values, allowing the text to blit say x += 20, moving every other string in my list over 20 units everytime it blits. I recently did some .format stuff with printing just in the console, is there a feature like this for screen.blit so I can use the same formatting in a pygame window? Included my code underneath. Thanks in advance :D import pygame NAMES = ['Deanerys T.', 'Jon S.', 'Gregor C.',

XSL formatting number with 'hyphens' every two digits

元气小坏坏 提交于 2019-12-24 07:06:05
问题 I have searched for days and found one example [here][1] [1]: XSLT formatting numbers, insert '-' after every 4 digits starting from the right most digit, but it doesn't seem to work out as expected. Here is what I need to happen. I have a number that is 7 digits like '1122334' and I need to coerce it to '11-22-33-4'. Here is my code so far: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:template match="/dataset"> <xsl:decimal

Print numbers in terms of engineering units in Python [duplicate]

爱⌒轻易说出口 提交于 2019-12-24 07:03:23
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Print number in engineering format How do I print numbers in scientific notation with powers that are multiples of 3? For example: 1.5e4 --> 15e3 1.27e-8 --> 12.7e-9 2.9855e-11 --> 29.855e-9 I'm looking for a function similar to the ENG button on a calculator. Is there a Python package somewhere that does this? 回答1: It appears there isn't such a feature yet (at least in Python 2.7), see: http://bugs.python.org

How to parse follow date in Java?

不问归期 提交于 2019-12-24 06:04:26
问题 Hello i need to parse this string Sun, 15 Aug 2010 3:50 PM CEST I'm using SimpleDataFormat in this way String date = "Sun, 15 Aug 2010 3:50 pm CEST"; DateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy h:mm a Z"); Date d = formatter.parse(date); but it throws an exception. Can you help me please? Thanks 回答1: SimpleDateFormat is sensitive to the Locale that is currently set. So it can be that there is a problem when trying to parse the format with your current one. With your

No instance of play.api.libs.json.Format is available for scala.Iterable[java.lang.String]

泪湿孤枕 提交于 2019-12-24 06:03:58
问题 Trying to map a simple class using play version 2.6.2 and scala 2.11.11 import play.api.libs.json._ import play.api.libs.json.util._ import play.api.libs.json.Reads._ import play.api.libs.json.Writes._ import play.api.libs.json.Format._ import play.api.libs.functional.syntax._ case class ObjectInfo ( names : Iterable[String], info : Iterable[String] ) object ObjectInfo { /** * Mapping to and from JSON. */ implicit val documentFormatter = Json.format[ObjectInfo] } getting: No instance of play

Scanf a char using %d

試著忘記壹切 提交于 2019-12-24 05:46:20
问题 I have a specific example below, which works perfectly fine if integers are inputted (see output1), when I try to scan a char using %d specifier in scanf function call I get the output2 below. So, my question is if input a char I hope the type specifier should convert it to an equivalent int value, if not a junk value, even in the either case it should print/segfault. But, here I'm getting continuous prints which I feel is wrong as scanf is getting bypassed every single time. I'm pretty

avoid extra zeros in number formatting in C#

喜你入骨 提交于 2019-12-24 05:31:22
问题 (First of all: this is not a duplicate of Format numbers with floating points and sign in textbox in C#) I am using the solution from dodald (https://stackoverflow.com/a/27510646/3179989) for formatting numbers with floating points and sign to make them aligned based on the floating point: textbox1.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}", number1); textbox2.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}", number2); textbox3.Text = String.Format("{0:+;-}{0,9:0.00000;0.00000}",

SQL Server 2005 - Format a decimal number with leading zeros (including signed decimals!)

那年仲夏 提交于 2019-12-24 04:44:28
问题 I need to format numbers like:- 1.99 21.34 1797.94 -300.36 -21.99 -2.31 Into a format mask of 0000.00, using SQL-Server 2005 T-SQL. Preserving the signed integers and the decimals after the dot. This would be used for text file exports for a financial system. It requires it to be in this format. e.g.- 0001.99 0021.34 1794.94 -0300.36 -0021.99 -0002.31 Previously, it was done in MS Access as Format([Total],"0000.00") but SQL-Server doesn't have this function. 回答1: ;WITH t(c) AS ( SELECT 1.99

Nginx raises 404 when using format => 'js'

微笑、不失礼 提交于 2019-12-24 04:25:32
问题 I upload images to my App using Ajax and an Iframe. In Development everything works like a charm. But in production Nginx suddenly raises a 404 error. When I look into the log, the request never hits the Rails app. So I guess it has something to do with my Nginx configuration (maybe gzip compression). The failing requests is send to "/images.js". Any ideas on how to solve this? Google couldn't help me... My Nginx config: server { listen 80; server_name www.myapp.de; root /var/www/apps/myapp