python-3.4

Pickle user inputs - Python 3 [closed]

孤街浪徒 提交于 2019-12-13 11:20:48
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I am pretty desperate, since I have tried to get this working in a long time. I'm making a text adventure where some user inputs choose the player's hp, dmg, you name it. I want to make a save function, but every time I load it, the player has default parameters. Example: class player: def __init__(self, hp, dmg

Arthimatic Quiz Not Accepting Correct Answers

*爱你&永不变心* 提交于 2019-12-13 09:16:44
问题 I am attempting to make an arithmetic quiz, but have run into this issue: Even if I input the correct answer, it seems to ignore the correct answer code and go straight to the incorrect answer code. Basically, it doesn't accept any right answers. import random num1 = (random.randrange(10)) num2 = (random.randrange(10)) correct1 = (num1*num2) ans1 = input("What is " + str(num1) + " multiplied by " + str(num2) + "? ") if ans1 == correct1: print("Correct! ") if ans1 != correct1: print("

Do string representations of dictionaries have order in Python 3.4?

拟墨画扇 提交于 2019-12-13 09:16:29
问题 I know dictionaries themselves in Python do not have order. However, I'm rather curious if when you call str() on a dictionary if it is always in the same order. It appears to be sorted (by key), no matter which order I add items: d={} d[5]=5 d[1]=1 d["z"]="z" d["a"]="a" s=str(d) print(s) I know a lot of people will be tempted to say it's not sorted, but please try to prove me wrong by getting unsorted results. So, are dictionaries converted to strings sorted, by default, in Python 3.4? 回答1:

How can I exit powerfactory using Python in Unattended mode?

心已入冬 提交于 2019-12-13 07:22:50
问题 I am new to Python scripting and I am currently trying to get acquainted with python scripting and DigSILENT Powerfactory. I have managed thus far to execute powerfactory, activate projects and execute a load flow but after my code ends, when I try to rerun it, it wont run. In order for it to run I need to close Spyder and reopen it. I believe this is related to the fact that powerfactory is still running in the background so I was wondering if there is any command that "forces" powerfactory

Killing subprocess after first line

帅比萌擦擦* 提交于 2019-12-13 07:18:32
问题 I am executing program which connects to external server from python. If user is not authenticated, the program asks for username and password. Here is how subprogram output looks: Authentication Required Enter authorization information for "Web API" <username_prompt_here> <password_prompt_here> I want to kill subprocess right after 'Authentication Required' is printed, but the problem is, that my code works wrong - subprocess is asking for credentials and after user provides it, the

Django Admin Page missing CSS in IIS

懵懂的女人 提交于 2019-12-13 06:02:49
问题 I am getting a similar error to this post, but it only happens when I go to the website I set up in IIS 2012R2. I am following this tutorial to start a web app, and I used this video to set up Django with IIS. I successfully set up the Django using IIS, but I a missing the CSS on the admin page. Note that the admin page displays the CSS items if I run the page using runserver command. python manage.py runserver But if I run it through http://127.0.0.1:8003/admin/ in IE (setup through IIS), I

How to destroy an .exe file(not converted from py) by run as the same script

时光怂恿深爱的人放手 提交于 2019-12-13 05:49:29
问题 I have a script that runs an .exe file via subprocess.Popen() , but I just realized, that .exe file keeps running even I close my script. Is there any way to stop running an .exe file via name of it or ID? That exe file is not converted from a py file, so I'm stuck. 回答1: If you run process = subprocess.Popen(...) then you could terminate the process later using process.terminate() . If the subprocess may create its own children then process.terminate() and/or process.kill() might not be

Python 3 unittest patch doesn't return desired value

你。 提交于 2019-12-13 04:41:22
问题 I am trying to use the unitttest mock framework (python 3.4.9) to mock one of the method in my test case. And it's failing as it doesn't return the mocked value. This is the simplest example. In my case I can't change the way method being invoked. mock method def patch_this_method(): return 100 Test Case import unittest from unittest.mock import patch from libs.util import patch_this_method import libs class TestLibs(unittest.TestCase): @patch('libs.util.patch_this_method', return_value="200"

How do I use a variable so that it is inside and outside of a function

我只是一个虾纸丫 提交于 2019-12-13 02:58:17
问题 I would like to know how I can use a variable in a function but then outside of the function as well. Here is a part of my code which is supposed to add 1 to the score when the answer is correct, then print out the overall score afterwards (there is more than one function so I need to the score to be outside of the function): score=0 def Geography(score): #Question 1 qa1= input("What is the capital of England? ") if qa1.lower() == ("london"): print ("Correct you gain 1 point") score=score+1

jenkins cannot run firefox: No protocol specified Error: cannot open display: :0

萝らか妹 提交于 2019-12-13 01:28:17
问题 I have installed jenkins as a service on linux mint. I am trying to run tests written in python and script cannot run firefox. This line is a problem. ... self.browser = webdriver.Firefox() ... When i log in as jenkins user, i can't run firefox. getting this error : (process:3758): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed No protocol specified No protocol specified Error: cannot open display: :0 Firefox works when i run it from my (logged in) user. 回答1: Just