How to deal with the parameters with script
<p>I print the args from: </p>

<pre><code>if __name__ == '__main__':
  print('The sys.argv is :\n',sys.argv)
</code></pre>

<p>and find that all the parameters transfer into string and i don't know how to deal with it.</p>

<p>Command <code>python3 MAX_HEAPIFY.py [1,2,3,4,5,6,7,8,9,10] 2</code></p>

<p>output: <code>['MAX_HEAPIFY.py', '[1,2,3,4,5,6,7,8,9,10]', '2']</code></p>

<p>You need to understand that python accepts all input on the command line as strings. It is up to you to process the args in your code. </p>

<p>Ideally you would use <code>argparse</code> to make this more robust, but for this example you can run a command like this:</p>

<pre><code>python3 MAX_HEAPIFY.py "1,2,3,4,5,6,7,8,9,10" 2
</code></pre>

<p>Then you will use <code>my_list = sys.argv[1].split(",")</code> to process your first arg as a list.</p>

<p>Obviously you need to deal with typecasting and things specific to your logic, but I hope this gives you a starting point. </p>

<p>Edit:</p>

<p>If you need to convert <code>my_list</code> to a list of ints, you can use a list comprehension like this:</p>

<pre><code>my_int_list = [int(i) for i in my_list if i.isdigit()]
</code></pre>

python python-3.x