答:
```python
import random
# 生成随机数并存入文件
with open("data1.txt", "w") as f:
nums = [random.randint(1, 100) for _ in range(10)]
f.write(" ".join(map(str, nums)))
print("随机生成的数字:", " ".join(map(str, nums)))
# 从文件中读取数据并进行冒泡排序
with open("data1.txt", "r") as f:
nums = list(map(int, f.read().split()))
for i in range(len(nums)):
for j in range(len(nums) - i - 1):
if nums[j] > nums[j + 1]:
nums[j], nums[j + 1] = nums[j + 1], nums[j]
# 将排序后的结果存入文件
with open("data2.txt", "w") as f:
f.write(" ".join(map(str, nums)))
# 显示结果
print("冒泡排序后的数字:", " ".join(map(str, nums)))
```