【发布时间】:2021-06-03 13:12:49
【问题描述】:
我正在使用python进行学校项目,我想知道如何创建一个具有简单这种效果的简单病毒
我试过这个: How do I use shutil to make a python file copy itself after doing a calculation?
还有这个: https://stackoverflow.com/questions/1186789/what-is-the-best-way-to-call-a-script-from-another-script
然后我不知道如何运行第二个副本
代码示例(我想运行一次)
import os
import shutil
##############
print("hello world")
shutil.copy(__file__, "copy.py") # Copies the file
exec(open("copy.py").read())# Executes the copied file if it is in the same directory as the other file
【问题讨论】: