摘要: from turtle import * def square(size=50, rgb='orange'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800,600) speed(0) n=10 fo 阅读全文
posted @ 2022-06-09 11:23 Rua!Rua!Rua! 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 1 class User : 2 def __init__(self,name='guest', password=111111, status=1): 3 self.name = name 4 self.password = password 5 self.status = status 6 de 阅读全文
posted @ 2022-06-06 10:48 Rua!Rua!Rua! 阅读(8) 评论(0) 推荐(0) 编辑
摘要: title = ['城市', '人口(万)'] info = [ ['南京', '850'], ['纽约', '2300'], ['东京', '3800'], ['巴黎', '1000'] ] with open('city1.csv', 'w', encoding='utf-8') as f: f 阅读全文
posted @ 2022-05-18 20:46 Rua!Rua!Rua! 阅读(8) 评论(0) 推荐(0) 编辑
摘要: with open('data1_2.txt','r',encoding='utf-8')as f: n=0 for line in f : if line.strip()=='': continue n+=1 print(f'共{n}行') with open('data1_1.txt', 'r' 阅读全文
posted @ 2022-05-14 12:32 Rua!Rua!Rua! 阅读(12) 评论(2) 推荐(0) 编辑
摘要: print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7)print(sum) 1.内置函数名称 2.赋值名称 3.局部变量 4.全局变量 def func1(a,  阅读全文
posted @ 2022-05-07 10:41 Rua!Rua!Rua! 阅读(14) 评论(0) 推荐(0) 编辑
摘要: import random print('用列表存储随机整数: ') ls = [random.randint(1, 100) for i in range(5)] print(ls) print('\n用集合存储随机整数: ') s1 = {random.randint(1,100) for i 阅读全文
posted @ 2022-04-20 20:42 Rua!Rua!Rua! 阅读(9) 评论(2) 推荐(0) 编辑
摘要: x = list(range(10)) print('整数输出1: ', end = '') for i in x: print(i, end=' ') print('\n整数输出2: ', end = '') for i in x: print(f'{i:02d}', end = '-') pri 阅读全文
posted @ 2022-04-06 22:36 Rua!Rua!Rua! 阅读(11) 评论(2) 推荐(0) 编辑
摘要: # 用法1:用于输出单个字符串或单个变量 print('hey, u') # 用法2: 用于输出多个数据项,用逗号分隔 print('hey', ' u') x,y,z = 1,2,3 print(x, y, z) # 用法3: 用户混合字符串和变量值 print('x = %d, y = %d, 阅读全文
posted @ 2022-03-25 20:55 Rua!Rua!Rua! 阅读(8) 评论(3) 推荐(0) 编辑