python参数,既有单引号又有双引号的解决办法

 

 

 

python参数,既有单引号又有双引号的解决办法:

使用双引号引起来,中间的双引号使用\转义,中间的单引号不转义,如下

python3 ./pluginTool.py out/228out/tr069Transform_ass.xml tr069Transform_ass modify /tr069Transform_ass:Device/tr069Transform_ass:Services/tr069Transform_ass:FAPService/tr069Transform_ass:CellConfig/tr069Transform_ass:NR/tr069Transform_ass:NGC/tr069Transform_ass:TA/tr069Transform_ass:TAC "{\"Trans\":true,\"Notification\":2,\"AccessList\":[\"Subscriber\"],\"Shell\":\"./scripts/TAC_Convert\",\"Links\":[{\"Xpath\":\"/duoam:InternetGatewayDevice/Services/FAPService[name='3333']/CellConfig/FIVEGNR/RAN/CommonInfo/FIVEGSTAC\",\"Config\":true}]}"

 

代码里读到的值才是我们期望的

val={"Trans":true,"Notification":2,"AccessList":["Subscriber"],"Shell":"./scripts/TAC_Convert","Links":[{"Xpath":"/duoam:InternetGatewayDevice/Services/FAPService[name='3333']/CellConfig/FIVEGNR/RAN/CommonInfo/FIVEGSTAC","Config":true}]}

 

posted @ 2023-04-03 20:55  LiuYanYGZ  阅读(319)  评论(0编辑  收藏  举报