2020/11/17
python的学习结束。
今天终于安装上了心心念念的pygame,用vscode还是挺强大的,比pycharm好用多了。
那么赶紧想一下今天我学习了哪些东西吧
1。
import random #导入随机模块
num = 1
yin_num = 0
shu_num = 0
while num <= 3:
if shu_num == 2 or yin_num == 2:
break
user = int(input('请出拳 0(石头) 1(剪刀) 2(布)'))
if user > 2:
print('不能出大于2的值')
else:
data = ['石头', '剪刀', '布']
com = random.randint(0, 2)
print("您出的是{},电脑出的是{}".format(data[user], data[com]))
if user == com:
print('平局')
continue
elif (user == 0 and com == 1) or (user == 1 and com == 2) or (user == 2 and com == 0):
print('你赢了')
yin_num += 1
else:
print('你输了菜鸡')
shu_num += 1
num += 1
大致学习了一些基础,另外要注意的是,python用的是:而不是;
https://blog.csdn.net/luanpeng825485697/article/details/78387573
太多太细了,准备用程序来学习,用这个来填补基础就可以,我靠要学的太多了我是真的服了
2.
name = "张起灵"
gender ="男"
age = "不清楚,反正很年轻"
print("姓名:%s, 性别: %s 年龄: %s"%(name,gender,age))
print("姓名:{}, 性别:{} 年龄:{}".format(name,gender,age))
print("姓名:{1},性别:{0} 年龄:{2} 学生姓名:{1}" .format(name, gender, age))
print("姓名:{name}, 性别:{gender} 年龄:{age} 学生姓名:{name}" .format(name = name ,gender = gender,age = age))
format函数,感觉还好,还不是很难。记住一点点了吧。
继续加油!!!!