我想以这样一种方式实现脚本,即一个人输入源文件的路径、目标文件的路径、源文件和目标文件,而不干扰代码。该脚本接受值,但在打开文件时,该脚本会引发错误。这是代码
path = [0] * 2
sourcefile = 0
destinationfile = 0
print("Please write your source path:")
input(path[0])
print("Please write your destination path:")
input(path[1])
print("Source name of your file is ")
input(sourcefile)
print("Destination name of your file is ")
input(destinationfile)
with open(r"%s"+"%s" % (path[0], sourcefile), 'r') as file_in:
问题从此刻开始with open。谁知道,请帮忙。
这里
你完全在滥用
input.实际上,您需要指定要向用户显示的文本作为参数。并且接收到的值
input作为结果返回,并且它必须显式分配给一个变量。也就是说,这两行需要改写成这样:
并以相同的方式重写其余的输入。