python --version // 首先查看系統中是否已經安裝了Python,若是沒有則繼續下一步 brew install python3 brew postinstall python3 //這個操做幫組安裝pip3 python3 --version //查看是否安裝成功 python3 //進入到交互模式 print('hello ~') exit()//退出交互模式
choco install Python3
python --version //剛安裝好,須要重啓Cmder窗口
下載PyCharm並在線註冊html
配置PyCharm環境python
下載並安裝 Atombash
給atom安裝script插件微信
setting->install -> script
cd kwy-python
atom ./
# 變量 name, age = 'keweiyang',30 print('{} is 30 yers old'.format(name))
# 分支 if if age < 28: print('not allowed') else: print('ok')
''' 循環 while for ''' number = 0 while number < 6: print(number) number = number + 1 else: print("done!") for number in range(0,6): if number == 4: break print(number)
class Person: # 構造函數,self 等價於 Java中的this def __init__(self, name): self.name = name def greet(self): return 'hello ' + name person = Person('keweiyang') print(person.greet())
import sys # 導入部分功能,導入math的pi from math import pi help(sys) # 經過dir函數查看sys提供了什麼功能 dir(sys) print(pi)
注意:Python中沒有分號,而是用換行符替換;沒有{},而使用冒號替換;構造函數中的self是顯示出現的等,除此以外,Python和Java存在 不少類似的地方。編輯器
Python | Java |
---|---|
String | String |
List | List,ArrayList, LinkedList 等 |
Dictionary | Map,HashMap, TreeMap,LinkedHashMap等 |
Set | Set,HashSet, TreeSet, LinkedHashSet 等 |
List | List,ArrayList, LinkedList 等 |
keweiyangdeMacBook-Pro:~ keweiyang$ brew search anaconda ==> Searching local taps... ==> Searching taps on GitHub... caskroom/cask/anaconda ==> Searching blacklisted, migrated and deleted formulae... keweiyangdeMacBook-Pro:~ keweiyang$ brew install caskroom/cask/anaconda Updating Homebrew...
export PATH=/usr/local/anaconda3/bin:$PATH
source .bash_profile
conda --help
python --version
choco install anaconda3 //安裝須要一段時間 conda --help //'conda' 不是內部或外部命令,也不是可運行的程序或批處理文件。出現上述信息,提示咱們須要設置環境變量
經過安裝Anaconda來生成Conda,而後經過Conda管理環境,給Python建立不一樣的環境,每一個環境均可以有特定的包(package),還能夠指定Python版本。函數
conda info --envs # conda environments: # root * C:\tools\Anaconda3
conda create --name keweiyang numpy pandas
activate keweiyang (在mac下執行source activate kewy)
conda remove --name keweiyang --all
conda list
conda search --full-name python
conda create --name kewy python=2.7.13
conda search blaze
conda install blaze
,完成以後,再經過conda list|grep blaze
conda search arrow --channel conda-forge
,接着執行conda config --add channels conda-forge
,而後就能夠正常使用了,conda search arrow
,conda install arrow
pip 安裝
,好比說安裝seepip install see
conda list|grep see
conda remove arrow
pip uninstall see
歡迎關注微信公衆號:木可大大,全部文章都將同步在公衆號上。post