4. 一份回炉重造的python基础练习(二)

不会就学啊,健忘就反复学啊,甭管什么,学它就完事儿了

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 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值