-7

我对下面的代码有疑问。为什么:不打印冒号 ( ) 等特殊字符?


lista = ("KK",3,'go');
listb = [':b2:','bthree','b7'];

print lista;
print listb; # works

lista = ("KK",3,':go');

print lista; # Show Nothing: what's wrong (I am lost)
4

4 回答 4

1

您提供的示例代码工作正常,带有冒号的数据完全按照您的预期打印。你一定在做其他不正确的事情。

于 2011-11-01T11:14:22.443 回答
0

it works

python
>>> lista = ("KK",3,'go')
>>> listb = [':b2:','bthree','b7']
>>> print lista
('KK', 3, 'go')
>>> print listb
[':b2:', 'bthree', 'b7']

can you paste a bigger chunk of program? the problem is definitely somewhere else!

furthermore your title says: "While Loop In Python?"... there are NO LOOPS in your code!

于 2011-11-01T12:27:33.490 回答
0

您的代码应该可以工作,请尝试删除分号;分号在 Python 中不是必需的,但在 Javascript 中是必需的。

    lista = ("KK",3,'go')
    listb = [':b2:','bthree','b7']

    print lista
    print listb 
于 2014-08-11T00:54:27.403 回答
0

它完美地工作......

>>> lista = ("KK",3,'go')
>>> listb = [':b2:','bthree','b7']
>>> print lista
('KK', 3, 'go')
>>> print listb
[':b2:', 'bthree', 'b7']

我不明白你的问题(0_o)

于 2011-11-01T11:36:22.120 回答