我已经在python中编写了一个代码,它使用/在一个文件夹中创建一个特定的文件,如果我想在windows中使用它不起作用的代码,有没有办法在Windows和Linux中使用代码.
在python我使用此代码:
pathfile=os.path.dirname(templateFile)
rootTree.write(''+pathfile+'/output/log.txt')
Run Code Online (Sandbox Code Playgroud)
当我在假设Windows机器中使用我的代码时,我的代码将无法正常工作.
如何在Linux和Windows中使用"/"(目录分隔符)?
我有这样的2个列表:
list1=['A','B']
list2=['A','C','D']
Run Code Online (Sandbox Code Playgroud)
我想在两个列表中进行比较,找出缺少的,额外的和条目没有变化,我这样访问它:
set1=set(list1)
set2=set(list2)
MissingName=set1.difference(set2)
AdditionalName=set2.difference(set1)
Run Code Online (Sandbox Code Playgroud)
这给了我遗漏和额外的条目,我怎么能找到无变化,哪个应该是A ??