概述
本人测试萝卜出生,测试做了快两年了,越来越觉得测试工作的重复性与枯燥性不能适应,决定转转开发,首当其冲就瞄上了python,不用多说了,直接开始吧!
首先肯定是输出与输入:
print("Hello World!")#这是基于一种仪式吧,对世界问好!
input("name:")
深层次输出:
name = input("name:")
age = input("age:")
job = input("job:")
mm = input("mm:")
ww = '''-------of where {_name}--------
name:{_name},
age:{_age},
job:{_job},
mm:{_mm}'''.format(_name=name,_age=age,_job=job,_mm=mm)
print(ww)
列表基础:
names = ["zhangyang","lidongmei",["fs","wz"],"wangza","yaoming"]print(names[0],names[1])print(names[:2])#切片
print(names[1:3])#切片
print(names[-3:])#切片
print(names[-1])#切片
names.append("liyang")#追加
names.insert(1,"chenzhonghua")#固定位置插入
names.insert(3,"小黄人")#固定位置插入
names[1] = "黑猫警长"#修改
names.remove("小黄人")#删除1
del names[0]#删除2
names.pop()#删除3(默认删除最后一个,输入下标固定删除)
print(names)print(names.index("wangza"))#查找列表数据的索引(即数据所在位置)
print(names[names.index("wangza")])
names.append("wangza")#追加
print(names)print(names.count("wangza"))#检查数据重复性
names.reverse()#数据反转
print(names)
names.sort()#排序
print(names)
names.clear()#清空
print(names)
names2= [1,2,3,4]
names.extend(names2)#合并列表
print(names,names2)
name2= names.copy()#软拷贝(有局限性)
name2 = copy.copy(names)#软拷贝1
name3 = names[:]#软拷贝2
name4 = list(names)#软拷贝3
name3 = names#完全拷贝
print(names)print(name2)
names[2] = "王炸"
print(names)print(name2)print(name3)print(names[2][1])importcopy
name2= copy.deepcopy(names)#深拷贝
print(names)print(name2)
基础循环:
#判断年龄
age = 60
guess_age = int(input("guess_age:"))
if guess_age == age:
print("yes,you got it.")
elif guess_age > age:
print("think smaller...")
else:
print("think bigger!")
#增加次数判断 1)
count = 0
age = 60
while True:
print("count:",count)
guess_age = int(input("guess_age:"))
if guess_age == age and count < 4:
print("yes,you got it.")
break
elif guess_age > age and count < 4:
print("think smaller,And count < 4...")
elif guess_age < age and count < 4:
print("think bigger!And count < 4")
else:
print("Game over!")
break
count = count +1
#增加次数判断 2)
count = 0
age = 60
while count < 4:
guess_age = int(input("guess_age:"))
if guess_age == age:
print("yes,you got it.")
break
elif guess_age > age:
print("think smaller,And count < 4...")
else:
print("think bigger!")
count = count +1
else:
print("More times than...!")
#增加次数判断 3)
age = 60
for i in range(4):
guess_age = int(input("guess_age:"))
if guess_age == age:
print("yes,you got it.")
break
elif guess_age > age:
print("think smaller,And count < 4...")
else:
print("think bigger!")
else:
print("More times than...!")
遍历打印:
for i in range(10):
print("-------",i)
for j in range(10):
print(j)
if j >5:
break
纯属手工小白,欢迎评论,不喜勿喷哈~O(∩_∩)O~~
最后
以上就是粗犷自行车为你收集整理的用python输出世界你好_"Hello World!" 我的python之旅开始了~的全部内容,希望文章能够帮你解决用python输出世界你好_"Hello World!" 我的python之旅开始了~所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复