Make a summary:
Maybe I haven't found a better method yet, but unfortunately, Python does not seem to support similar shell scripts, Perl The scalar interpolation is supported, so it cannot be displayed like the following. This kind of personal feeling is the clearest and convenient method.
For example, if a user loses two variables: 'bucketball ', 'bucketing', shell, or per, the following shows I love bucketball and specify the best. # Shellinput = 'basebucketball 'input2 = 'shortming' print' I love $ input and $ input2 the best' # Perl $ input = 'bucketball '$ input2 = 'shortming' print' I love $ input and $ input2 the best 'so how can I display it in Python, there are the following methods: select as needed. I hope to directly support the display method similar to the escape script in the future, and regard $ as an escape character :) 1 Import Sys
2 Input = SYS. argv [ 1 ]
3 Input2 = SYS. argv [ 2 ]
4
5 S = ' I love ' + Input + ' And ' + Input2 + ' The best '
6 Print (S)
7
8 S = ' I love % s and % s the best ' % (Input, input2)
9 Print (S)
10
11 Params = { ' Input ' : Input, ' Input2 ' : Input2}
12 S = ' I love % (input) s and % (input2) s the best ' % Params
13 Print (S)
14
15
16 From String Import Template
17 S = Template ( ' I love $ input and $ input2 the best ' )
18 S = S. substitute (input = Input, input2 = Input2)
19 Print (S)