ASCII 树,但 python 不同意
ASCII tree, but python does not agree
我有这个 python 脚本,其中有一个用于文档目的的树:
# This is the tree, generated with:
# $ tree -A a
# a
# └── tree
if __name__ == '__main__':
print 'It runs'
如果我运行它:
File "xxx.py", line 4
SyntaxError: Non-ASCII character '\xe2' in file xxx.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
我知道我可以解决这个错误添加例如:
#coding: utf8
在我脚本的顶部,但我很好奇:为什么 tree
手册页说 -A
输出 ASCII:
-A Turn on ANSI line graphics hack when printing the indentation lines.
但是 python
没有将树识别为 ASCII
?谁错了?还是我漏掉了什么?
这不是 ASCII。 ANSI line grpahics 与 ASCII 不同;而 ASCII 没有画线字符。 ASCII 仅定义字节 0x00 - 0x7F。
我有这个 python 脚本,其中有一个用于文档目的的树:
# This is the tree, generated with:
# $ tree -A a
# a
# └── tree
if __name__ == '__main__':
print 'It runs'
如果我运行它:
File "xxx.py", line 4
SyntaxError: Non-ASCII character '\xe2' in file xxx.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
我知道我可以解决这个错误添加例如:
#coding: utf8
在我脚本的顶部,但我很好奇:为什么 tree
手册页说 -A
输出 ASCII:
-A Turn on ANSI line graphics hack when printing the indentation lines.
但是 python
没有将树识别为 ASCII
?谁错了?还是我漏掉了什么?
这不是 ASCII。 ANSI line grpahics 与 ASCII 不同;而 ASCII 没有画线字符。 ASCII 仅定义字节 0x00 - 0x7F。