有没有办法在Linux中将Linux样式的shell替换转换为Windows替换?
假设在Linux环境中有一个命令:
class StateWidget(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
style1 = "background-color: yellow"
style2 = "background-color: black"
# animation doesn't work for strings but provides an appropriate delay
animation = QtCore.QPropertyAnimation(self, 'styleSheet')
animation.setDuration(150)
state1 = QtCore.QState()
state2 = QtCore.QState()
state1.assignProperty(self, 'styleSheet', style1)
state2.assignProperty(self, 'styleSheet', style2)
# change a state after an animation has played
# v
state1.addTransition(state1.propertiesAssigned, state2)
state2.addTransition(state2.propertiesAssigned, state1)
self.machine = QtCore.QStateMachine()
self.machine.addDefaultAnimation(animation)
self.machine.addState(state1)
self.machine.addState(state2)
self.machine.setInitialState(state1)
self.machine.start()
在Windows中:
my_command=cd
${my_command} .. OR $my_command .. resolves to cd ..
我想要它,以便如果我的环境是Windows,那么我可以接受命令并将其替换为Windows样式替换:
示例输入/输出:
SET my_command=cd
%my_command% .. resolves to cd ..
谢谢!
答案 0 :(得分:-2)
for x in sys.argv:
if x.startswith("$"):
print "%%%s%%"%(x[1:])