- 博客(5)
- 收藏
- 关注
原创 用Python画五角星
import turtle turtle.forward(200) turtle.right(144) turtle.forward(200) turtle.right(144) turtle.forward(200) turtle.right(144) turtle.forward(200) turtle.right(144) turtle.forward(200) turtle.done() 这里用到了一个叫turtle的库函数,类似于画板 通过命令乌龟的运动,来控制画笔 如图 ...
2022-02-19 20:42:28
1012
原创 python中的map函数
语法 map( function, iterzble, ...) 返回值 python 3 返回迭代器 实例 def num(x): return x**2 index=map(num,[1,2,3]) print(index) 输出 <map object at 0x00000187708B0160> #使用list()转换为列表 print(list(index)) 输出 [1, 4, 9] ...
2022-02-03 17:14:48
965
原创 python中的end=‘‘,同一行输出
print(1) print(2) print(1,end=' ') print(2) 输出 1 2 1 2 end='' 起到了让1,2在同一行输出的作用,也就是下一行承接上一行 例子 print(1,end='2') print(3) 输出 123
2022-01-26 12:22:09
1696
原创 Python中的strip()用法
strip() 用于删除字符串首尾的指定字符(默认为空格)或字符序列 str = "AAabcAabcAAA" print(str.strip('A')) #指定字符串A 输出结果 abcAabc 中间的不删除
2022-01-26 11:18:54
897
原创 Python中的小数保留输出
#输入一个浮点类型的数 num = float(input()) #保留两位小数输出 print('%.2f'%num) #注意!!!这里要加单引号,有两个%
2022-01-24 15:25:11
1273
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅