256 Kilobytes

Answers in Scripting and Automation | By August R. Garcia

Published 2 weeks agoSat, 26 Oct 2019 01:56:29 -0700

41 views, 0 RAMs, and 0 comments

Tags: Python, Error Messages, String Formatting

Profile Photo - August R. Garcia August R. Garcia LARPing as a Sysadmi... Portland, OR
🗎 198 🗨 987 🐏 299
Site Owner

This is technically a different error message, but is what was causing the issue.

string = "The value is one hundred (100)."

# Raises an error 
print("This is 100% of a sentence:\n%s" % string)
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: %o format: an integer is required, not str

# This does not raise an error
print("This is 100%% of a sentence:\n%s" % string)
# This is 100% of a sentence:
# The value is one hundred (100).

TL;DR: Escape the percent symbol (%) with two percent symbols when using string formatting in Python. 

Download more RAM. 🐏 ⨉ 0 Posted by August R. Garcia 2 weeks ago 🕓 Posted at 26 October, 2019 01:56 AM PDT

Sir, I can do you a nice SEO.

Post a New Comment

To leave a comment, login to your account or create an account.

Do you like having a good time?

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account
You can also login to an existing account or recover your password. All use of this site is subject to terms outlined in the terms of service and privacy policy.