Hi how do I get a £ to print in python 2.4.1.
if I type print "£" in the terminal it works fine
if I try to to that from a script it comes up with a Deprecationwarning no encoding selected and prints (don't know how to get the character to appear on here, but it is a A with a "^" above it) and the £, ie. it prints A£
if I include

# -*- coding: utf-8 -*-
in the script the Deprecation Warning disappears but it still print A£
thanks

Recommended Answers

I have not such old Python, but for me works normally in Windows:

# -*- coding: cp1252 -*-
print(u"£")
Microsoft Windows XP [versio 5.1.2600]
(C) Copyright 1985 - 2001 Microsoft Corp.

I:\test>pound_sign_test.py
£
Jump to Post

All 2 Replies

I have not such old Python, but for me works normally in Windows:

# -*- coding: cp1252 -*-
print(u"£")
Microsoft Windows XP [versio 5.1.2600]
(C) Copyright 1985 - 2001 Microsoft Corp.

I:\test>pound_sign_test.py
£

Uinicode should work regardless of the encoding used.

#u.py
print unichr(163)
print u"\u00A3"

Microsoft Windows [Versjon 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Med enerett.

C:\>python u.py
£
£
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.