方法一:第一行:# coding=utf-8
接着: print ur'''静夜思
床前明月光,
疑似地上斑。
举头望幽处,
低头思井空。'''
方法二:#coding=utf8
s = u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
print s
接着: print ur'''静夜思
床前明月光,
疑似地上斑。
举头望幽处,
低头思井空。'''
方法二:#coding=utf8
s = u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
print s
2015-11-24
print r'''
"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
我是看了下面才顿悟的,大伙儿看我下面。。。
"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
我是看了下面才顿悟的,大伙儿看我下面。。。
2015-11-24
s = 'Python was started in1989 by "Guido".'
b = 'Python is free and easy to learn'
print s,b
b = 'Python is free and easy to learn'
print s,b
2015-11-24
#Enter a code
print 45678+0x12fd2;
print 'Learn Python in imooc';
print 100<99;
print 0xff == 255;
print 45678+0x12fd2;
print 'Learn Python in imooc';
print 100<99;
print 0xff == 255;
2015-11-24
#coding=utf8
s = u'''
静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
print s.encode('utf8')
s = u'''
静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
print s.encode('utf8')
2015-11-22
最赞回答 / qq_小太阳_20
并非一概而论的不能包含'和"。如果最终的嵌套关系是可以让raw语句之外的'和'、"和"匹配起来,并且print语句格式正确的话,就可以正常运行。
2015-11-21
sum = 0
x = 1
n = 1
while True:
sum=sum+pow(2,n-1)
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+pow(2,n-1)
n=n+1
if n>20:
break
print sum
2015-11-21
a = 'python'
print 'hello,', a or 'world'
b = ''
print 'hello,', b or 'world'
a or 'world' #a为非空字符,所以为True,根据或运算与短路计算原则,只要有一个布尔值为True,计算结果就是True,所以直接输出python.
b or 'world' #b为空字符,所以为False,根据或运算与短路计算原则,所以直接输出world。
运算结果为
hello,python
hello,world
print 'hello,', a or 'world'
b = ''
print 'hello,', b or 'world'
a or 'world' #a为非空字符,所以为True,根据或运算与短路计算原则,只要有一个布尔值为True,计算结果就是True,所以直接输出python.
b or 'world' #b为空字符,所以为False,根据或运算与短路计算原则,所以直接输出world。
运算结果为
hello,python
hello,world
2015-11-21