Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Python - Non Riesco a trovare l'errore in questo programma
Forum - Python - Non Riesco a trovare l'errore in questo programma

Avatar
lorenzoscarrone (Normal User)
Pro


Messaggi: 92
Iscritto: 16/11/2011

Segnala al moderatore
Postato alle 14:55
Giovedė, 25/07/2013
premetto ho cominciato a studiare python oggi, ho provato a compilare il mio programma ma mi da il seguente errore:
Codice sorgente - presumibilmente Python

  1. File "./android_manager.py", line 7
  2.     def banner:
  3.               ^
  4. SyntaxError: invalid syntax



Codice sorgente - presumibilmente Python

  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import os
  5. import subprocess
  6.  
  7. def banner:
  8. print ###################################
  9. print #                                                                         #
  10. print #     Android-Manager                                                #
  11. print #          edited by HackerScarrow                       #
  12. print #                                                                    #
  13. print ###################################
  14.  
  15. def check_device_connection:
  16.  os.system("adb wait-for-device")
  17.  os.system("adb start-server")
  18.  
  19. def check_options:
  20.  print "1] send file to device  "
  21.  print "2] get file from device "
  22.  print "3] interact with device "
  23.  print "4] reboot device"
  24.  print "5] get serial number of device"
  25.  print "6] quit"
  26.  
  27. def check_path_file:
  28.  get_file = input("enter path file here:")
  29.  return get_file
  30.  
  31. def show_sdcard_contents(dir):
  32.  os.system("adb shell ls /sdcard/"+dir)
  33.  
  34. #####################################################
  35. ################### DEVICE PATH #####################
  36.  
  37. def_dev_path = " /sdcard/"
  38.  
  39. ################### SYSTEM PATH #####################
  40.  
  41. user = os.system(pwd)
  42. def_sys_path = user
  43.  
  44. #####################################################
  45.  
  46. banner
  47. check_device_connection
  48. check_options
  49. choice = input("choose an option: ")
  50.  
  51. if choice = 1:
  52.         file = check_path_file
  53.         send = "adb push "+file+def_dev_path
  54.         os.system(send)
  55. if choice = 2:
  56.         show_sdcard_contents()
  57.         print "Where I can find your file ?"
  58.         choose_dir = input("choose device directory: ")
  59.         show_sdcard_contents(choose_dir)
  60.         print " Did u find your file ? "
  61.         aws = input("[yes]|[no] : ")
  62.          if aws = "yes" :
  63.           choose_file = input("Enter file name : " )
  64.           pull_file = def_dev_path+choose_file
  65.           os.system("adb pull "+pull_file+" "+def_sys_path)
  66. if choice = 3:
  67.         os.system("adb shell ")
  68.  
  69. if choice = 4:
  70.         os.system("adb reboot")
  71. if choice = 5:
  72.         os.system("adb get-serialno")
  73. if choice = 6:
  74.         os.system("exit")
  75. print ################## See you soon ##########################


Ultima modifica effettuata da lorenzoscarrone il 25/07/2013 alle 14:58
PM Quote
Avatar
Poggi Marco (Member)
Guru


Messaggi: 969
Iscritto: 05/01/2010

Segnala al moderatore
Postato alle 15:06
Giovedė, 25/07/2013
Ciao!

Il comando def serve a dichiarare una funzione. Di conseguenza, dopo il nome, vanno inserite le parentesi tonde:
(
Codice sorgente - presumibilmente Python

  1. ...
  2. def banner():
  3.     print"############"
  4. ...

)

PM Quote