Reputation: 305
below is the snippet in question:
print '{:─^10}'.format('') # Print '─' character 10 times
I'm using this to create nice console borders and such. The problem is, running this in my py file with # coding UTF-8 gives me: ValueError: Invalid conversion specification
If I run this same script in the python shell, it spits out the escaped characters: '\xc4\xc4\xc4\x...'
I don't know how (in my script) to get this to print out the '─' character. It can print the '─' character just fine if I use print '─' because of the UTF-8 encoding, but for some reason it won't allow it in the string.format() function.
Any suggestions? I'm sure this is probably easy to fix, but i'm VERY new to python programming.
Thanks in advance.
Upvotes: 1
Views: 1374
Reputation: 120678
Assuming you're using Python2, you need to use unicode (u''
) strings:
print u'{:─^10}'.format(u'')
Upvotes: 2