標籤:available internet programs welcome keyword
關鍵字和標識符
下列的標識符是 Python3 的關鍵字,並且不能用於通常的標識符。關鍵字必須完全按照下面拼字:
>>> help()Welcome to Python 3.5‘s help utility!If this is your first time using Python, you should definitely check outthe tutorial on the Internet at http://docs.python.org/3.5/tutorial/.Enter the name of any module, keyword, or topic to get help on writingPython programs and using Python modules. To quit this help utility andreturn to the interpreter, just type "quit".To get a list of available modules, keywords, symbols, or topics, type"modules", "keywords", "symbols", or "topics". Each module also comeswith a one-line summary of what it does; to list the modules whose nameor summary contain a given string such as "spam", type "modules spam".help> keywordsHere is a list of the Python keywords. Enter any keyword to get more help.False def if raiseNone del import returnTrue elif in tryand else is whileas except lambda withassert finally nonlocal yieldbreak for not class from or continue global pass
Python 中 我們不需要為變數指定資料類型。所以你可以直接寫出 num1 = 1 ,這樣變數 abc 就是整數類型。如果你寫出 num2= 1.0 ,那麼變數 abc 就是浮點類型。
>>> num1=1>>> num2=1.0>>> name="wuxinglai">>> print(type(num1))<class ‘int‘>>>> print(type(numnum1 num2 >>> print(type(numnum1 num2 >>> print(type(num2))<class ‘float‘>>>> print(type(name))<class ‘str‘>>>>
通過上面的例子你應該理解了如何在 Python 中定義變數,也就是只需要輸入變數名和值就行了。Python 也能操作字串,它們用單引號或雙引號括起來。
從鍵盤讀取輸入
[email protected]:~/file/1# vim input_age.py
#!/usr/bin/python3#coding:utf8number=int(input("Please Input your age:"))if number >= 18: print ("你已經是成年人 Your age is %s and You are already an adult" %number)else: print ("你是未成年 Your age is %s You are a minor" %number)
[email protected]:~/file/1# python3 input_age.py
Please Input your age:18
你已經是成年人 Your age is 18 and You are already an adult
[email protected]:~/file/1# python3 input_age.py
Please Input your age:12
你是未成年 Your age is 12 You are a minor
本文出自 “有志者,事竟成” 部落格,謝絕轉載!
循序漸進-python-02