Python 入门
下载Anconda
地址:https://www.anaconda.com/download/
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
直接一次点击安装
IDE jupyter notebook
在windowns下cmd里面打入 jupyter notebook
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
这就代表你的jupyter notebook启动了
点击new下面的python3便可以新建一个新的界面
<figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
认识一下常用的窗口
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
分别表示新建文件,打开文件,复制,保存,下载等
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
每一行代表一个cell,他的意思就是字面意思啦
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
然后还有一个比较常用的就是Kernel
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
当你进入死循环,就点击interrupt或者restart
Python的基本数据类型 数字
python的基本数值类型包括 整形,浮点数,字符串,复数
通过type函数查看数据类型
<figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
类型的转化
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
我们继续掏出一个函数:isinstance()
判断数据类型是否为某一数据类型
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
Python的基本数据类型——字符串
字符串之所以区别于其他数据类型,是因为它是被包含在引号里面的
你可以用单引号,也可以用双引号
划重点:但是不能一边单引号,一边双引号!
当然,有时候我们必须单引号和双引号都得使用:,#代表注释
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
转义 \
Python用反斜杠(\)来转义字符
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
常用字符串相关操作方法
len()取长度
-
字符串连接
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
字符串索引 与R不同,python是从0开始
字符串切片image
<figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
有时,我可能想打印 \t
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
网友评论