admin管理员组文章数量:1794759
Python培训笔记
Python
趋向于模块化编程;自动化运维,自动化后才可以智能化。
程序、UI、游戏开发、软件开发、攻击脚本(批量处理)、AI
主流操作系统搭载python -python 2.7,未来趋势是 python 3.X;python是跨平台的,windows需要自行下载安装,Unix(linux和Mac OS)自带python。
www.runoob/manual/pythontutorial3/docs/html/index.html
python实例blog.csdn/lxy210781/article/details/80561334
配置后在python安装目录下运行cmd,输入“pip”,出现如下界面即可:
打开idle-File-New File-输入print("shhsgs")-Run-Run Module(F5)
import os #导入os模块
if os.path.exists
//没有执行成功
pip install virtualenv
virtualenv project
source project/bin/activate
//没记上,自己查会blog.csdn/m0_38124502/article/details/78090902
pip freeze > pip.txt
pip install -r pip.txt
pip install ipython
pip install notebook
cpython基于C语言的基础上开发而来,JPython专门调用java,还可以调用C++、。
'python string',单引号或双引号包裹的内容称为字符串。
特殊字符\\n,前面加一个r才可以正常执行。br表示bytes型字符串
字符串对象,字符串对象自带方法,python中dir(s)列出对象的函数,help寻找使用方法help(s.split)
s = “string”
s object
object.method()
列表,中括号包裹,逗号分隔各元素[item1,item2,item3]
列表函数list()
id(l1),指针函数,指向内存中一个函数
append、index、clear、pop、insert、remove、extend、copy、reverse、count
def f1():#0号语句块
print('abcdefg')#1号语句块
1+1#1号语句块
函数后面有:表示复合语句
while 1:
print(‘ok’)
break
while True:
print(‘ok’)
break
第一段比第二段代码执行快,因为计算机是01编码
课后复习,自行编写石头剪刀布游戏,人和电脑玩石头剪刀布,输入人的选择,电脑随机,输出猜拳结果同时输出电脑的选择:
import random
role=["shitou","jiandao","bu"]
p=input("please input your choice:")
c=random.choice(role)
print(c)
result_l=[p,c]
winlist=[["shitou","jiandao"],["jiandao","bu"],["bu","shitou"]]
loselist=[["shitou","bu"],["bu","jiandao"],["jiandao","shitou"]]
if result_l in winlist:
print(result_l)
print("p win!")
elif result_l in loselist:
print(result_l)
print("computer win!")
else:
print(result_l)
print("all win!")
剪刀石头布公式
X = (A-B)%3
X= 0 ,1 ,2
Y = X * (X %2 - 0.5)
Y = 0
Y = 1 * (1 - 0.5) = 0.5
Y = 2 * (0 - 0.5) = -1
版权声明:本文标题:Python培训笔记 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1687080130a131445.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论