摘要:
# 用矩形绘制花瓣 from turtle import * def square(size=50,rgb='pink'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800,600) speed(0) 阅读全文
摘要:
class User: def __init__(self,name='guest',password='111111',statu='1'): self.name=name self.password=password self.statu=statu def info(self): if sel 阅读全文
摘要:
def is_valid(x): if len(x) != 18: return False else: for i in x: try: i = int(i) except: if ord(i) != ord('X'): return False return True with open('da 阅读全文
摘要:
with open('data3.txt','r+', encoding='UTF-8') as f: x = [line.strip('\n') for line in f] x.pop(0) x_print = [eval(i) for i in x] print(f"原始数据:\n{x_pri 阅读全文
摘要:
print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 第一个sum,内置作用域.第二个sum变量名,第三个sum局部作用域,第四个sum全 阅读全文
摘要:
import random print('用列表存储随机整数: ') ls = [random.randint(1, 100) for i in range(5)] print(ls) print('\n用集合存储随机整数') s1 = {random.randint(1,100) for i in 阅读全文
摘要:
#实验任务1 # 基础操作练习: 列表及列表推导式、格式化、类型转换 x = list(range(10)) print('整数输出1: ', end = '') for i in x: print(i, end=' ') print('\n整数输出2: ', end = '') for i in 阅读全文
摘要:
# print输出的几种用 # 用法1:用于输出单个字符串或单个 print('hey, u') # 用法2:用于输出多个数据项,用逗号分隔 print('hey', ' u') x,y,z = 1,2,3 print(x, y, z) # 用法3:用户混合字符串和变量值 print('x = %d 阅读全文