随笔分类 - python
摘要:位置传参 定义:实参与形参的位置依次对应。 序列传参 定义:实参用*将序列拆解后与形参的位置依次对应。 关键字传参 定义:实参根据形参的名字进行对应。 字典关键字传参 定义:实参用**将字典拆解后与形参的名字进行对应。 作用:配合形参的缺省参数,可以使调用者随意传参。 print("位置传参 ")
阅读全文
摘要:源文件每行后面都有回车,所以用下面输出时,中间会多了一行 try: with open("F:\\hjt.txt" ) as f : for line in f: print(line) except FileNotFoundError: print("读取文件出错") 有两种方法处理: 1.print后面带 end='',表示不换行 t...
阅读全文
posted @ 2019-07-13 21:54
zhengyunbo66
摘要:active =True while active: message =input("\nPlease input your name:\n") if message =='q': break print("welcome " + message + " come to our website!") with open('guest_book...
阅读全文
posted @ 2019-07-13 21:49
zhengyunbo66
摘要:1 print(1, 2, 3, 4) # 1 2 3 4 2 print(' 以下是给定sep="#"的打印方式') 3 print(1, 2, 3, 4, sep="#") # 1#2#3#4 4 print('以下关键字参数end="\n\n\n\n\n"来换五行新行') 5 print(1,
阅读全文

浙公网安备 33010602011771号