1.我和python的第一次亲密接触
生活随笔
收集整理的這篇文章主要介紹了
1.我和python的第一次亲密接触
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.shell交互式
python 在窗口中打印 (1)打印字符串 >>> print "Hello,python!" Hello,python! (2)字符串相加 >>> print( "well water" + "river" ) >>> print "well water" + "river" well waterriver>>> print( "well water" + "river" + "\n" )*8 乘以8,即打印8次 well waterriver well waterriver well waterriver well waterriver well waterriver well waterriver well waterriver well waterriver 【課后題】print( "well water" + "river" + "\n" )+8為什么報(bào)錯(cuò)? (3)四則運(yùn)算 >>> print(5+3) 8 >>> 5+3 8 >>> 123456789 * 987654321 1219326311126352692.腳本
#coding:utf-8 #支持中文print "...魚C工作室..."; temp = input("temp = ") #input函數(shù):接受用戶的輸入,賦值給 guess = int(temp) # 強(qiáng)制轉(zhuǎn)換 if guess == 8: #注意:有冒號(hào)print("正確\n") else:print("錯(cuò)誤\n") print("游戲結(jié)束\n")執(zhí)行命令:
python test.py 或者 test.py3.python中的內(nèi)建函數(shù)(BIF) http://blog.csdn.net/qq_20545159/article/details/46334323
gjw@gjw:~/TEST_PYTHON$ python Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> dir(__builtins__) ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__', '__package__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'] >>>總結(jié)
以上是生活随笔為你收集整理的1.我和python的第一次亲密接触的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 7.30
- 下一篇: 2.变量/字符串/if/while/数据