cost 278 ms
如何在 Java 中使用 3 个参数格式化字符串 - How to format a String using 3 parameters in Java

我有两个类,其中一个我创建了一个格式化方法,它将按宽度(output 字符串的长度)、位置(小数点后的位数)和我的值来格式化字符串 output期待格式化。 另一个 class 有一个使用 format 方法打印值的方法。 我试图自己弄清楚如何做到这一点,但我遇到了错误并且没有得到我正在寻找的 ou ...

CodenameOne Java Hello World 示例中的 String.Format“错误:找不到符号” - CodenameOne Java String.Format "error: cannot find symbol" on Hello World example

超级简单的 String.format("this is a test %d",5) 在我的 HelloWorld CodenameOne 项目中不起作用:我收到“错误:找不到符号”。 我使用什么格式似乎并不重要,我总是得到同样的错误。 这似乎是一个导入问题,尽管我没有导入默认设置之外的任何特殊包 ...

Pylint 不喜欢 string.format() 并希望我使用 f-strings。 这是可以修复的吗? - Pylint doesn't like string.format() and wants me to use f-strings. Is this fixable?

我已经升级到 pylint 2.15.2,每当我运行 pylint 时突然收到很多consider-using-f-string警告,其中我对字符串使用了 % 格式。 我理解为什么 Pylint 不想使用旧的 % 格式,但是当我尝试改用 string.format() 时,我也遇到了这个错误。 以 ...

带有列表的 Str.format 以创建过滤器 - Str.format with a list to create filter

有许多类似的问题有点简单,但我似乎找不到我要找的东西。 我正在尝试通过位置编号的 int 列表过滤 dbc.Carousel 中的图像列表。 任何以给定数字开头的图像标题都将与位置相关联。 所以,最初,我想要所有以 1、2、3、4 或 5 开头的图像。我有:def imageFilter(locFi ...

Python,获取 ValueError:在使用正则表达式的字符串中的格式变量时,字段名称中出现意外的“{” - Python, getting ValueError: unexpected '{' in field name when using format variable in a string with regex

此代码完全按照应有的方式对字符串运行查询。 bInfoPList = re.findall('{searchString}'.format(searchString = searchString), content, re.M + re.S) 此代码返回:“ValueError:字段名称中出现意外 ...

ArgumentType:“Big Decimal”与指定格式“%d”的类型不匹配 - ArgumentType: 'Big Decimal' does not match the type of the format specified '%d'

我试图通过将值提取到字符串然后以这种方式打印来打印出值的 ArrayList。 我从 DTO 类中获取值,并且我使用的string.format方法出现错误,我说 ArgumentType:“Big Decimal”与指定格式“%d”的类型不匹配 数量在 DTO 类中定义为 BIG De ...

如何使用 string.format 将数组的元素对齐到列中 - How to align elements of an array into columns using string.format

我正在尝试使用 string.format 重新创建与此类似的直列: 这是我到目前为止的代码,但我有点卡住了,因为它只正确获取第一个元素,并且最后的一对整数没有对齐。 它效率低下且有点随机 - string.format 对我来说仍然很新。 这是我的代码打印的内容: 如果有人可以提供帮助 ...

有没有办法避免在 Python 中包含引号的格式化字符串中使用双引号 - Is there a way to avoid double quotation in formatting strings which include quotations inside them in Python

这应该不是一个难题,但我已经研究了将近一天! 我想创建一个必须采用以下格式的查询:'lat':'###','long':'###' 其中###s 代表纬度和经度。 我正在使用以下代码生成查询: 然而,结果将是一些类似的东西,它的开头和结尾都有“”:“'lat':'40.66','long':'-73 ...

print(engine) 不显示正确的连接 URL - print(engine) does not display the correct connection URL

我正在尝试在虚拟环境中使用 python 将数据帧写入 sql server。 我可以使用我的 pyodbc 连接从服务器读取数据,但无法使用该连接对其进行写入,因此我使用的是 sqlalchemy 引擎,并且凭据存储在 .env 文件中。 打印原始字符串返回: 但是在打印引擎时它会返回: ...

Lua 字符串包含双引号和/或单引号问题 - string.format("%q") 后缀为 \13 - Lua issues with string containing double and/or single quotes - string.format("%q") suffixes with \13

在 lua 中,我正在阅读一个文本文件,其中的行可能包含单引号或双引号,例如:“L'habitude begin comme un fil de soie et devient vite un câble d'acier” - Proverbe espagnol 这些行是这样使用的: 一切正常,但 ...

需要以 int 形式计算分钟数,然后以 double 形式计算秒数。 方法应使用 Java 中的格式字符串 - Required to calculate the number of minutes as an int, then the seconds as a double. method should use a format string in Java

我正在创建一个公共方法 String toString() 。 要求是采用一个随机生成的数字,即十分之一秒(例如 6500)并将其转换为 int 分钟和双秒。 我需要使用这个格式字符串: "%s \t %d mins %.1f secs \t %s" 。 我正在努力解决这个问题,因为我创建了以下方法 ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM