English 中文(简体)
Python 中的奇怪符号
原标题:Strange symbols in Python
  • 时间:2012-05-24 18:46:16
  •  标签:
  • python-2.7

我正在研究Python, 并且一直在实验逃生序列 < code> v 和 < code> f 。 输出似乎给我放这2个逃生序列的地方提供了奇怪的符号。 由于网站的一些垃圾邮件预防政策, 我无法张贴输出的图像 。 有人能给出问题所在的想法吗? 谢谢 。

问题回答

Escape-sequences are documented here:
http://docs.python.org/reference/lexical_analysis.html#string-literals

v is a vertical tab
f is a form feed

If you print them in the REPL you get the hexadecimal value (0c).
Example:

>>>  f 
 x0c 

As with some other conventions, the x escape-sequence is inherited from C.
Reference: http://www.python.org/dev/peps/pep-0223/

Aside:
If you prefer the ASCII code to the hex code you can use ord():

>>> ord( f )
12




相关问题
Curve fitting with lmfit for Mossbauer spectroscopy

Im pretty new to lmfit and I keep running into this error. My dataset is pretty large ~27000 points of data from I gather: my error msg import numpy as np import matplotlib.pyplot as plt from lmfit ...

Python SocketServer: sending to multiple clients?

Well, I m trying to build a small python prgram with a SocketServer that is supposed to send messages it receives to all connected clients. I m stuck, I don t know how to store clients on the ...

Is there no mysql connector for python 2.7 on windows

While I see a bunch of links/binaries for mysql connector for python 2.6, I don t see one for 2.7 To use django, should I just revert to 2.6 or is there a way out ? I m using windows 7 64bit django ...

How to update the image of a Tkinter Label widget?

I would like to be able to swap out an image on a Tkinter label, but I m not sure how to do it, except for replacing the widget itself. Currently, I can display an image like so: import Tkinter as ...

PyScripter for Python 2.7

How to run PyScripter if you have Python 2.7 installed? There is a command line parameter for Pyscipter to tell it which pythonXX.dll to use, but I can t get this working.

How to set time limit on raw_input

in python, is there a way to, while waiting for a user input, count time so that after, say 30 seconds, the raw_input() function is automatically skipped?

热门标签