_1 python syntax of basic grammar Overview

Chapter: Tutorial, basic syntax, data types, interpreter, comment, operator,
Outline
  1. View python version
  2. Implement a python3.x program, hello world
  3. Encoding format
  4. Identifier (i.e., class names, method names)
  5. python reserved word (keyword library)
  6. Note
  7. Line with the indentation
  8. Multi-line statement
  9. Numeric type (Number) (int, bool, float, complex)
  10. String (String)
  11. Blank line
  12. Waiting for user input
  13. The same line shows multiple statements, use a semicolon division
  14. Multiple statements constitute code groups (like if, while, def and class this compound statement, the first line to start with keywords, a colon (:) end, after the bank constitute one or more lines of code code group)
  15. Print output
  16. import和from...import
  17. Command line parameters
 
 
 
text
Print output
The default print output is the new line, if you want to achieve does not need to wrap at the end of variable plus end = "":
example:
from __future__ import print_function
x='a'
y='b'
print(x,end='')
print (y)
 
Interactive Programming
Command prompt, type "Python" command to start the Python interpreter:
$ python3
 
Scripted Programming
The following command to execute the script:
python3 hello.py
 
import 与 from...import
In the python with the import or to import from ... import corresponding module.
The entire module (somemodule) introducing the format: import somemodule
Import a function from a module, the format is: from somemodule import somefunction
从某个模块中导入多个函数,格式为: from somemodule import firstfunc, secondfunc, thirdfunc
将某个模块中的全部函数导入,格式为: from somemodule import *
import sys
print('命令行参数')
for i in sys.argv:
print('文件地址:'+i)
sys = str(sys.path) # sys.path返回的是列表,强制转换为字符串格式方便输出
print('\n路径为 \n' +sys)
 

Guess you like

Origin www.cnblogs.com/TomBombadil/p/10977873.html