i have made program stores score attached name in .txt file. however, want print alphabetical order of name attached score. when run program come error io.unsupportedoperation: not writable here code: file = open(class_name , 'r') #opens file in 'append' mode don't delete information name = (name) file.write(str(name + " : " )) #writes information file file.write(str(score)) file.write('\n') linelist = file.readlines() line in sorted(linelist): print(line.rstrip()); file.close() you have opened file read only, attempted write it. file left open, attempt read it, if in append mode, file pointer @ end of file. try instead: class_name = "class.txt" name = "joe" score = 1.5 file = open(class_name , 'a') #opens file in 'append' mode don't delete information name = (n...
i want run python code in apache2(ubuntu 14.04) server. have followed these steps , getting error: step 1: configuration 1: have created directory , file under /var/www/cgi-bin configuration 2 : have edited /etc/apache2/sites-available/000-default.conf alias /cgi-bin /var/www/cgi-bin <directory "/var/www/cgi-bin"> options indexes followsymlinks execcgi addhandler cgi-script .cgi .py allow </directory> <directory /var/www/cgi-bin> options </directory> step 2: and python script is: index.py #!/usr/bin/env python import cgi; import cgitb;cgitb.enable() print "content-type: text/plain\n" print "<b>hello python</b>" step 3: when ran through chrome browser using: url : http://localhost/cgi-bin/index.py step 4: i getting error in error-log malformed header script 'index.py': bad header: hello python you should end header \r\n, must print out yet \r\n signal body coming. (i...
Comments
Post a Comment