I know this question has been asked here but the solution does not work for me. I am using python 3.4.

You are watching: Non-empty format string passed to object.__format__

I have the following formatting in my script :

print ( " 0:20 1:32".format( files.name.split("/")<-1>, sizeof_fmt(files.size), str( formatted_timestamp ), files.owner, files.version_id, files.etag ))This works in python 2.7.x. But in 3.4 I get the error:

File "test.py", line 3, in file_print versionid, etag ))TypeError: non-empty format string passed to object.__format__I tried this:

print ( " 0:20 1:32s".format( files.name.split("/")<-1>, sizeof_fmt(files.size), str( formatted_timestamp ), files.owner, files.version_id, files.etag ))But I still get the same error. I even converted the versionid and etag to strings and end up getting the same error. Can someone explain this to me?

Etag look like this 9893532233caff98cd083a116b013c0b, versionid is None

See Question&Answers more detail:os
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…

Please log in or register to add a comment.


*

Please log in or register to answer this question.


1 Answer


0 votes
*
answeredOct 24by 深蓝(5.2m points)

One of your parameters is a type that doesn"t have their own __format__() method, so object.__format__() is used instead.

object.__format__() doesn"t support any formatting options, including field widths and alignment, which is why you get the error.

Conversion to string first should help, but you do need to put your conversion after the field name; instead of !s4:11s use 4!s:11s, etc:

print ( " 0:20 1:32s".format( files.name.split("/")<-1>, sizeof_fmt(files.size), str(formatted_timestamp), files.owner, files.version_id, files.etag))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…

Please log in or register to add a comment.


Related questions


0 votes
0 views
1 answer
Python TypeError: not enough arguments for format string
Here"s the output. These are utf-8 strings I believe... some of these can be NoneType but it fails immediately, before ones like that... instr = ... TypeError: not enough arguments for format string Its 7 for 7 though? Question&Answers:os...
askedOct 17by 深蓝(5.2m points)
0 votes
2 views
1 answer
Python os.chdir is modifying the passed directory name
I am trying to change the current working directory in python using os.chdir. I have the following code: import os os.chdir("C:UsersJoshDesktop20130216 ... UsersJoshDesktopx8130216" Can anyone help me? See Question&Answers more detail:os...
askedOct 24by 深蓝(5.2m points)
0 votes
2 views
1 answer
Python argparse custom actions with additional arguments passed
import argparse class customAction(argparse.Action): def __call__(self, parser, args, values, option_string=None): setattr(args, self.dest, values) parser = ... ? Everything I have tried has errored out. See Question&Answers more detail:os...
askedOct 24by 深蓝(5.2m points)
0 votes
27 views
1 answer
Python Panda series - extract non empty/null to variable
Have the following DF: parent_path child level table field absent_flag logic 2 dummy.map amap 3 table_input1 MAP_A 1 5 dummy.array<> b_array 3 ... cleanup to the string but is there more elegant way to extract "FROM_ARRAY_TABLE" ?...
askedJan 27in Technique<技术>by 深蓝(5.2m points)
0 votes
26 views
1 answer
Python Panda series - extract non empty/null to variable
Have the following DF: parent_path child level table field absent_flag logic 2 dummy.map amap 3 table_input1 MAP_A 1 5 dummy.array<> b_array 3 ... cleanup to the string but is there more elegant way to extract "FROM_ARRAY_TABLE" ?...
askedJan 27in Technique<技术>by 深蓝(5.2m points)
0 votes
0 views
1 answer
php - date() method, "A non well formed numeric value encountered" does not want to format a date passed in $_POST
I unfortunately can"t use DateTime() as the server this project is on is running PHP v.5.2. the line in question: $aptnDate2 = date("Y-m-d", ... a date with this date value and strtotime()? thanks! See Question&Answers more detail:os...
askedOct 17by 深蓝(5.2m points)
0 votes
2 views
1 answer
Python TypeError: unsupported operand type(s) for /: "str" and "float"
My code: total=tef+tpf-price I"ve got this error: total=tef+tpf-price unsupported operand type(s) for -: "float" and "str" How do I fix it? See Question&Answers more detail:os...
askedOct 24by 深蓝(5.2m points)
0 votes
4 views
1 answer
Python TypeError: "float" object cannot be interpreted as an integer
My code: for i in range( 3.3, 5 ): print( i ) The above code have to print: 3.300000 4.300000 but the interpreter of Python 3.4.0 ... error: TypeError: "float" object cannot be interpreted as an integer See Question&Answers more detail:os...
askedOct 24by 深蓝(5.2m points)
0 votes
2 views
1 answer
Python error - TypeError: unsupported operand type(s) for +: "NoneType" and "str"
I am trying to debug an existing script and got the below error when I run the script. ./check_tandbergvideo CE s 10.50.174.138 This script do the efforts ... the second line of the code H323 has correct syntax? See Question&Answers more detail:os...
askedOct 24by 深蓝(5.2m points)
0 votes
1 view
1 answer
Python & Selenium Click and "TypeError: string indices must be integers"
I am currently working on a piece of code and have done many readings using the documentary and looked at many examples, but still I cannot fix ... Using a different function for clicking Appreciate it! See Question&Answers more detail:os...

See more: Put A Baby In Me Tumblr - Honey : Bfh! Breeding Kink


askedOct 24by 深蓝(5.2m points)
Login using GitHub
*

欢迎来到 hyakkendana-hashigozake.com|知识分享社区! 一个分享知识,传递知识,学习知识的程序员开发者社区!

Welcome to hyakkendana-hashigozake.com Knowledge Sharing Community for programmer and developer-Open, Learning and Share

Related questions


Just Browsing Browsing


<1>pug - How can i get a guild id using discord oauth2 in pug?
<2>css 点击ul切换其中li标签内的图片
<3>c# - Marshal a struct containing pointer to array
<4>select - T-SQL - Pivot out Distinct N rows for each group
<5>arrays - Parsing a JSON file in JavaScript for power system
<6>okhttp 链接websocket 报错求解原因
<7>javascript - localStorage not defined using axios interceptor in NextJS
<8>craco和react-app-rewired有什么区别?
<9>wordpress - How to use value from a custom form tag
<10>swiftUI 有没有比较好用table 组件

548k questions

547k answers

4 comments

25.3k users


Most popular tags


javascriptpythonjavac#Howandroidc++phpioshtmlsqlrcnode.js.netiphoneasp.netcssreactjsjqueryrubyWhatAndroidobjectivemysqllinuxIsgitPythonwindowsWhyregexangularswiftamazonexcelalgorithmgooglemacoshowJavavisualbashCantypescriptmultithreadingPHPUsingscalaangularjsapachespringperformancepostgresqldatabaseflutterjsonrustarraysC#vbadartdjangowpfxmlvue.jsIngoGetjQueryxcodejsfhttpGooglemongodbstringshellooppowershellSQLC++securityassemblydockerJavascriptAndroid:DoeshaskellwebConvertazuredebuggingdelphivb.netSpringdatetimepandasoraclemath

Friend Link:
Powered by Question2Answer
Donate
Theme by Q2A Market&&hyakkendana-hashigozake.com
...