使用当前浏览器访问考试宝,无法享受最佳体验,推荐使用 Chrome 浏览器进行访问。
更新时间: 试题数量: 购买人数: 提供作者:
有效期: 个月
章节介绍: 共有个章节
我的错题 (0道)
我的收藏 (0道)
我的斩题 (0道)
我的笔记 (0道)
顺序练习 0 / 0
随机练习 自定义设置练习量
题型乱序 按导入顺序练习
模拟考试 仿真模拟
题型练习 按题型分类练习
易错题 精选高频易错题
学习资料 考试学习相关信息
import re
text = "PythonThereare2applesand5orangesPython"
numbers = re.findall(r'\d+', text)
numbers = [int(i) for i in numbers]
print(numbers)
z1 = 3 + 4j
z2 = 1 - 2j
z_sum = z1 + z2
print("实部:", z_sum.real)
print("虚部:", z_sum.imag)
# 写入文件
with open('test.txt', 'w') as f:
f.write("ABC\\n123\\n")
# 读取文件
with open('test.txt', 'r') as f:
content = f.read().replace('\\n', '') # 注意引号间没有空格
print(content) # 程序输出
def func(x):
return x * 2
result = func("Hi") + "!"
d = {'a':1}
d.update(b=2, c=3)
print(d.get('a',4)) # 第一空
print(d.get('d',4)) # 第二空
input.txt中的内容:
I love Python
with open('input.txt', 'r', encoding='utf-8') as file:
content = file.read().strip() # 读取全部内容
swapped_content = content.swapcase()
print(swapped_content) # 打印到控制台
s = " Python "
result = s.strip().upper().replace("PY", "Ja")
print("处理结果:", result)