jadianes / kdd-cup-99-spark

PySpark solution to the KDDCup99
Other
99 stars 64 forks source link

what does 'sys.argv[]' mean? #3

Open ResistWu opened 6 years ago

ResistWu commented 6 years ago

Hi there, I've found some problems when I was running your code and I couldn't understand after 7 days debugging and thinking. So I want to ask. One is what does 'sys.argv' mean in this segment. Cause it always print the this line and quit, if I annotation the exit raw it would become an error about 'sys.argv'. if __name__ == "__main__": if (len(sys.argv) != 3): print("Usage: /path/to/spark/bin/spark-submit --driver-memory 2g " + \ "KDDCup99.py max_k kddcup.data.file") sys.exit(1) The second is could you please tell me what does this segment do in the code, I couldn't understand it. QUQ `if name == "main": if (len(sys.argv) != 3): print("Usage: /path/to/spark/bin/spark-submit --driver-memory 2g " + \ "KDDCup99.py max_k kddcup.data.file") sys.exit(1)

set up environment

max_k = int(sys.argv[1])
data_file = sys.argv[2]
conf = SparkConf().setAppName("KDDCup99") \
  #.set("spark.executor.memory", "2g")
sc = SparkContext(conf=conf)`

If you can answer my questions I'll be great honored. Thank you for your time.

rikonaka commented 6 years ago

U can speak chinese at all...