print(‘hello,world’) print(‘你好,北京’)
name="刘梦雅" print(name)
程序交互:
name=input“请输入你的名字” print(name)
a=2*20 print(a,type(a))
name=input(‘请输入你的名字‘) print(name,type(name))()
print(true,type(true))
choice=input(‘请输入你猜的数字’) if choice==‘2’ print(‘我请你吃饭’) else print(‘你请我吃饭’)
flag = true;
count =1;
while flag:
print(count);
count=1
while true:
print(count)
count=count+1
if count==101
break
count=0 while count<10; count =count +1 if count ==7; continue ; print(count )
comment =input(‘请输入你的评论’)
if ‘傻子’ in comment:
print (‘您输入的为敏感词汇,请重新输入’)
count = 1
while True:
print (count )
if count == 3:break
count +=1
else
print(‘循环正常‘)
输出 1
2
3
count =1
flag = True
while flag :
print (count)
if count == 3:
flag=False
count+=1
else :
print (‘循环正常完毕‘)
输出:1
2
3
循环正常完毕
name=input(‘请输入你的名字:’) age =input(‘请输入你的年龄:’) hobby=input(‘请输入你的爱好:’) ms =‘我叫%s,今年%d,爱好是%s’ % (name,int(age),hobby) print(ms)
2)第二种
dic = {‘name’:‘oldboy‘,‘age‘:15,‘hobby‘:‘踢足球‘}
msg=‘我叫%(name)s,今年%(age)d,爱好是%(hobby)s’ % dic
print(msg)
再格式化输出中单纯的显示% 用%%解决
name=input(‘请输入你的名字:’) age =input(‘请输入你的年龄:’) msg=‘我叫%s,今年%d,学习进度为1%%’ % (name,int(age)) print(msg)
print(int(True)) print (int(False)) 输出:1 0 True print(bool(100))
and or not
print (1 or 3) 输出 1 print (1 and 3 ) 3 print (0 or 2) 2 print(0 and 2) 0 print (1>2 or 3 and 4) 4
原文:https://www.cnblogs.com/hnlmy/p/9520262.html