数据小站
数据科学成长之路

python基础

pip命令

pip list/freeze ==> 列出现有包
pip list -o ==> 查看可升级包
pip install <包名> ==> 在线安装
pip install <包名> -d <目录> ==> 下载不安装
pip install <本地包路径地址> ==>本地安装包
pip uninstall <包名> ==> 卸载
pip install -U <包名>==>升级
pip show <包名> ==> 显示包详细信息
pip show -f <包名> ==> 显示包路径
pip search <包名> ==> 搜索包

759200-20170414161622126-889540131.png

格式化字符串

一般形式 ==> “I’m %s. I’m %d year old” % (‘Vamei’, 99)
字典形式 ==> “I’m %(name)s. I’m %(age)d year old” % {‘name’:’Vamei’, ‘age’:99}
更多形式==> %[(name)][flags][width].[precision]typecode
flags参数[+/-/”/0] +/-表示右/左对齐。”为一个空格,表示在正数的左侧填充一个空格,从而与负数对齐。0表示填充0
“%[flags][width].[precision=2]typecode=f” ==> “%06.2f” %(12.35684) ==> ‘012.36’
“%[(name)][flags=-0][width=6]typecode=s” ==> “%(name)-05s” %{“name”:”a”} ==> ‘a ‘
format形式 ==> “{}”.format() ==> “{0} is {1}”.format(“bob”, “14”)
fromat字典形式 ==> “The usage of {language}”.format(language = “Python”)
转义 ==> “%%” “{{}}”

赞(0) 打赏
未经允许不得转载:技术文档分享 » python基础

评论 抢沙发