a=[1,2,3]
print "the list is ?%"%(a)
Run Code Online (Sandbox Code Playgroud)
我想打印出这样一行:the list is?[1,2,3]
我不能在一行内完成,我必须这样做:
print " the list is :%"
print a
Run Code Online (Sandbox Code Playgroud)
我想知道我是否可以打印出与字符串格式和一行列表相结合的内容.
这是我在编辑器上编辑并在 shell 上编译的代码。
如果我输入整数19,当我打印出c时,它仍然['1','9']不是[1,9]我想要的。我在交互式解释器上尝试了这个,而不是编译 python 文件,它起作用了。
a = raw_input("Please enter a positive number ")
c = []
c = list(a)
map(int, c)
Run Code Online (Sandbox Code Playgroud)