不会就学啊,健忘就反复学啊,甭管什么,学它就完事儿了
文章目录
1. 前菜
# 来吧,两天从头再撸一遍python基础
print("Hello python")
print(5 % 2 + 4 / 2 + 0.7)
print("i love", end=' ')
print('python')
formatter = "{} {} {} {}"
formatter1 = "{}"
print(formatter.format(1, 2, 3, 4))
print(formatter1.format([1, 2, 3, 4]))
age = input("how old are you")
height = input("how tall are you")
weight = input("how much do you weight")
print(f"you're a {age} old,{height} tall and {weight} heavy people.")
# 打开一个txt文件
"""
通常使用传参的形式不固定参数,而是由参作者自由选择
from sys import argv
scripe,filename = argv
"""
filename = "xxx.txt"
txt = open(filename, 'w')
print(txt.read())
"""
open:打开文件,r-只读,w-写入,a-追加
close:关闭文件
readline:只读取文件的一行
truncate:清空文件
write:写入文件
seek():控制读写位置,从0开始
"""
txt.truncate()
line1 = input()
line2 = input()
txt.write(line1)
txt.write('\n')
txt.write(line2)
txt.close()
## 函数
def