fix the write file compatibility on windows platform.
							parent
							
								
									ef9585ce8a
								
							
						
					
					
						commit
						940f1ddebf
					
				|  | @ -28,7 +28,7 @@ import asyncio | ||||||
| import tornado | import tornado | ||||||
| from tornado.web import Application | from tornado.web import Application | ||||||
| 
 | 
 | ||||||
| CONST_APP_VERSION = "MaxBot (2023.07.08)" | CONST_APP_VERSION = "MaxBot (2023.07.09)" | ||||||
| 
 | 
 | ||||||
| CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" | CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" | ||||||
| 
 | 
 | ||||||
|  | @ -227,9 +227,14 @@ def web_server(): | ||||||
| 
 | 
 | ||||||
| def preview_question_text_file(): | def preview_question_text_file(): | ||||||
|     if os.path.exists(CONST_MAXBOT_QUESTION_FILE): |     if os.path.exists(CONST_MAXBOT_QUESTION_FILE): | ||||||
|         question_text = "" |         infile = None | ||||||
|         with open(CONST_MAXBOT_QUESTION_FILE, "r") as text_file: |         if platform.system() == 'Windows': | ||||||
|             question_text = text_file.readline() |             infile = open(CONST_MAXBOT_QUESTION_FILE, 'r', encoding='UTF-8') | ||||||
|  |         else: | ||||||
|  |             infile = open(CONST_MAXBOT_QUESTION_FILE, 'r') | ||||||
|  | 
 | ||||||
|  |         if not infile is None: | ||||||
|  |             question_text = infile.readline() | ||||||
| 
 | 
 | ||||||
|             global txt_question |             global txt_question | ||||||
|             try: |             try: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue