#!/uer/bin/env python # _*_ coding: utf-8 _*_ #格式1 a = ‘abc‘ for i in range(len(a)): print a[i],‘(%d)‘% i
a (0)
b (1)
c (2)
#格式2 for A,i in enumerate(‘abc‘): print i,A
a 0
b 1
c 2
#格式2.1 b = raw_input(‘wartyouname:‘) for i,j in enumerate(b): print b[i],‘(%d)‘% i
wartyouname:ssdf
s (0)
s (1)
d (2)
f (3)
代码一打我这边显示可以,前台一看就是乱码。愁死。就得截图了。
#!/uer/bin/env python # _*_ coding: utf-8 _*_ who = ‘kingfei‘ what = ‘NI‘ print ‘We are the‘,who,‘who say‘,what,what,what,what print ‘We are the %s who say %s ‘ % (who,(what + ‘ ‘) *4) #注意代码‘空格‘
输出:
We are the kingfei who say NI NI NI NI
We are the kingfei who say NI NI NI NI
时间: 2024-11-02 00:21:06