笨办法学Python3 习题22 到现在为止你学到了什么

发布时间 2023-10-05 19:59:42作者: 萹豆

目前为止书中学到,后续继续补充

内置函数:

  • print(x)
  • input(x)
  • f"xx {a} xx {b }xx."  // ''xx {} xx {} xx. ''format(a,b)  // ''xx'' a ''xx'' b ''xx.''
  • open(x) // open(x,"w") 
  • x.read()
  • x.seek(0)
  • x.readline()
  • x.close()
  • x.truncate()
  • x.write(b)
  • int(x)
  • float(x)
  • len(x)

关键字:

  • return   xxx
  • def
  • from
  • import
  • False
  • True

转义字符:

  • \n
  • \a
  • \t
  • \b
  • \f
  • \'
  • \"
  • \\

可选参数:

  • end="x"

运算符号:

()*  /   +  -

模块导入:

  • from sys import argv
  • from os.path import exists 

解包:

script, arg1=argv   

定义函数:

def  函数1(参数1,参数2):

       命令

def  函数2(*args):

       arg1,arg2 = args

       命令 

def  函数3():

       命令 

 

变量1 = 5+ 函数1(变量2,(函数2 / 函数3))  # 调用函数再将结果赋值给变量

函数2(变量1,变量3)                                             # 调用函数