x=3
y=5
z=x
x=y
y=z
print(x,y)
5 3
x=3
y=5
x,y=y,x
print(x,y)
5 3
print("I love pytnon.\nI love me.")
I love pytnon.
I love me.
print('I love pytnon.\nLet\'s love me.')
I love pytnon.
Let's love me.
print("D:\\three\\two\\one\\now")
D:\three\two\one\now
原始字符
print(r"D:\three\two\one\now")
D:\three\two\one\now
一句话的末尾加\表示没完
print("D:thre\n\ yy")
D:thre
\ yy
长字符串
print("""1
2
3""")
1
2
3
字符串乘法
print("我每天爱自己三遍!"*3)
我每天爱自己三遍!我每天爱自己三遍!我每天爱自己三遍!
print('\\')
\
print("D:\three\two\one\now")
D: hree wo\one
ow
字符串加法=拼接
'520'+'1314'
'5201314'
"""用python设计第一个游戏"""
temp=input("不妨猜一下现在咩咩心里想的数字:")
guess=int(temp)
if guess==8:
print("你是咩咩心理的蛔虫么")
print("哼,猜中了也没奖励")
else:
print("猜错啦")
print("游戏结束")
"""用python设计第一个游戏"""
counts=3
while counts>0:
temp=input("不妨猜一下现在咩咩心里想的数字:")
guess=int(temp)
if guess==8:
print("你是咩咩心理的蛔虫么")
print("哼,猜中了也没奖励")
break
else:
if guess<8:
print("小啦~")
else:
print("大啦~")
counts=counts-1
print("游戏结束")
print('I love pytnon.\nLet\'s love me.')
I love pytnon.
Let's love me.
print('\\')
\
print("D:\three\two\one\now")
D: hree wo\one
ow