python大神作品_Python大神成长之路: 第一次学习记录
一、Python發展史
二、Python2 or 3
博主選擇了Python3.
從官網下載Python www.python.org
Windows安裝python3.5、python2.7。安裝好后可能需要調整一下path
【右鍵計算機】--》【屬性】--》【高級系統設置】--》【高級】--》【環境變量】--》【在第二個內容框中找到 變量名為Path 的一行,雙擊】 --> 【Python安裝目錄追加到變值值中,用 ; 分割】
如:原來的值;C:\python27,切記前面有分號
三、第一個代碼:
當然是"hello word"
print "hello word"
四、變量
變量名只能是 字母、數字或下劃線的任意組合
變量名的第一個字符不能是數字
以下關鍵字不能聲明為變量名
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
例子:
name = "tom"
五、編碼
Python3 已完美支持UTF-8,博主的所有Python均采用Utf8,
utf8: 中文漢字3bytes、英文1個字節
六、注釋
三個引號可實現多行注釋。#單行注釋
7、初識模塊
可使用import導入第三方模塊、自定義模塊等。
查看導入模塊目錄
1 importsys2 print(sys.path)
View Code
8、輸入
在Python3中input,python2中raw_input
>>> username = input("your name:")
your name:Otcsnow
>>> print(username)
Otcsnow
9:條件語句、循環語句
if...else、if...elif...else、
while
for
a = 3
if a > 3:
print ("big")
elif a<3:
print("less")
else:
print("equal")
while a < 10:
print("while loop", a)
a += 1
for i in range(5,a,2):
print("for loop,", i)
equal
('while loop', 3)
('while loop', 4)
('while loop', 5)
('while loop', 6)
('while loop', 7)
('while loop', 8)
('while loop', 9)
('for loop,', 5)
('for loop,', 7)
('for loop,', 9)
Thanks.
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的python大神作品_Python大神成长之路: 第一次学习记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python折线图样式_Python金融
- 下一篇: python字符串数字求和_python