【发布时间】:2016-11-05 01:25:44
【问题描述】:
我在 ubantu 版本 16.04 中使用 ipython 笔记本并运行此代码,
word = 'Rushiraj'
length = 0
for char in 'rushiraj':
length = length + 1
print('There are', length,'character')
我得到这个输出: ('有', 8, '字符')
输出中出现这个单引号和圆括号的原因是什么?它不应该在那里!
【问题讨论】:
-
您正在使用 Python 2 运行适用于 Python 3 的代码。
-
^这个。试试
print 'There are', length,'character'
标签: python python-3.x loops python-2.x