python3系列(1)-pip、内置对象、运算符

##python:一种解释型、面向对象、动态数据类型的高级程序设计语言

计算机的存在是为了计算数据、存储数据 计算数据存储在内存中,持久化存在硬盘上

pip管理扩展库

1、常用命令

pip download package[==version]
pip freeze [> requirements.txt]
pip list
pip install package[==version]
pip install package.whl 
pip install -r requirements.txt
pip install --upgrade package
pip uninstall package[==version]

2、使用配置文件配置更改下载源

[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/

配置文件放置位置

Linux下: ~/.pip/pip.conf
windows下:用户文件夹下\pip\pip.ini

3、使用命令行临时改变pip源

pip install -i <mirror> --trusted-host <mirrorhost> package
例如
pip install -i http://pypi.douban.com/simple/  --trusted-host pypi.douban.com  pandas

国内源:

内置对象

对象类型:数字(int,float,complex)、字符串(str)、字节串(bytes)、列表(list)、字典(dict)、元组(tuple)、集合(set、frozenset)、布尔型(bool)、空类型(NoneType)、异常、文件、其他迭代对象、编程单元

>>> r = zip("abc","12")
>>> ("a","1") in r
True
>>> ("a","1") in r
False

python运算符

python

>>> [1,2,3]+["a","b"]
[1, 2, 3, 'a', 'b']
>>> "A"+1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: must be str, not int
>>> True+3
4
>>> False+3
3
>>> "a"*10
'aaaaaaaaaa'
>>> [1,2,3]*3
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> (1,2,3)*3
(1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> 'Hello'>'world'
False
>>> ord("H")
72
>>> ord("w")
119
>>> c = [1,2,3,4]
>>> d = list(map(str,c))
>>> d
['1', '2', '3', '4']
>>> str([1,2,3])
'[1, 2, 3]'
>>> list(str([1,2,3]))
['[', '1', ',', ' ', '2', ',', ' ', '3', ']']
>>>
>>> eval(str([1,2,3]))
[1, 2, 3]
>>> fp=open(r'D:\mytest.txt','a+')
>>> print('Hello world!',file=fp)
>>> fp.close()
Table of Contents