一、Pycharm的安装和配置
1.pycharm下载
PyCharm 是一款功能强大的 Python 编辑器,具有跨平台性。 PyCharm 的下载地址:http://www.jetbrains.com/pycharm/download/#section=windows
2.安装
tar zxf pychrm-community-2018.3.tar.gz -C /usr/local ##解压
cd pychrm-community-2018.3/bin
./pycharm.sh
3.输入账号密码
4.新建一个project
5.配置工程目录
二、初识pycharm
三.常用快捷键
设置 ctrl + alt + s
快速创建文件 alt + insert
自动格式化 ctrl + alt + l
快速注释代码 ctrl + /
快速取消注释代码 ctrl + /
复制一行代码 ctrl + d
撤销操作 ctrl + z
自动导入 alt+enter
快速更改文件名 shift+F6
四、导入包:两种方法
#1. 进入设置-项目-project interpreter +
#2. terminal—》pip3 install 包
pip3 install 包 -i https://pypi.douban.com/simple ##使用国内豆瓣镜像源速度很快
第一个小代码,查看微信用户信息
import itchat
##1. LOGIN weixin
itchat.auto_login(hotReload=True)
##2. get friends information,return friends list [1,2,3,4…]
##every friend information saved as dict
friends = itchat.get_friends()
print (friends)
print (type(friends))
##first friend information is yours
mine = friends[0]
name= mine['Nickname']
Signature = mine ['Signature']
#init male female other =0
male=female=other = 0
for friend in friends[1:]:
sex=friend['Sex']
if sex == 1:
male +=1
elif sex ==2:
female +=1
else:
other +=1
print("""
%%%%%%%%%%%%%%%%%%%%%%%%%weixin information%%%%%%%%%%%%%%%%%%%%%%%%
Name: %s
Signature: %s
Male friends count: %d
Female friends count: %d
""" %(name,Signature,male,female,other))