JohnnyFromBF
JohnnyFromBF

Reputation: 10191

In Python, what do %25s, %28s, %15s, %3s etc mean?

I've heard of string formatting, but what the heck are these %25s, %28s, %15s, %3s in this snippet:

return "Scan Name: %25s\nTarget(s): %25s\nPolicy: %28s\n\nRisk Summary\n%s\n%15s %3s\n%15s %3s\n%15s %3s\n\n%15s %3s" % ( report, prefs['TARGET'], policy,'-'*36,'High', severity['3'], 'Medium', severity['2'], 'Low', severity['1'], 'Open Ports', severity['0'])

Upvotes: 1

Views: 11507

Answers (1)

Wooble
Wooble

Reputation: 90037

This is a format specification.

In your case, %25s will format the appropriate value as a string with a minimum field width of 25 characters, for example.

Upvotes: 5

Related Questions