python-3.5

How can I correct the error ' AttributeError: 'dict_keys' object has no attribute 'remove' '?

旧时模样 提交于 2020-01-10 18:58:46
问题 I was trying shortest path finder using dijkstra algorithm but It seems not working. Can't figure out what the problem is. Here are the code and the error message. (I'm working on Python 3.5. https://www.youtube.com/watch?v=LHCVNtxb4ss) graph = { 'A': {'B': 10, 'D': 4, 'F': 10}, 'B': {'E': 5, 'J': 10, 'I': 17}, 'C': {'A': 4, 'D': 10, 'E': 16}, 'D': {'F': 12, 'G': 21}, 'E': {'G': 4}, 'F': {'E': 3}, 'G': {'J': 3}, 'H': {'G': 3, 'J': 3}, 'I': {}, 'J': {'I': 8}, } def dijkstra(graph, start, end):

How can I correct the error ' AttributeError: 'dict_keys' object has no attribute 'remove' '?

↘锁芯ラ 提交于 2020-01-10 18:58:15
问题 I was trying shortest path finder using dijkstra algorithm but It seems not working. Can't figure out what the problem is. Here are the code and the error message. (I'm working on Python 3.5. https://www.youtube.com/watch?v=LHCVNtxb4ss) graph = { 'A': {'B': 10, 'D': 4, 'F': 10}, 'B': {'E': 5, 'J': 10, 'I': 17}, 'C': {'A': 4, 'D': 10, 'E': 16}, 'D': {'F': 12, 'G': 21}, 'E': {'G': 4}, 'F': {'E': 3}, 'G': {'J': 3}, 'H': {'G': 3, 'J': 3}, 'I': {}, 'J': {'I': 8}, } def dijkstra(graph, start, end):

Python3 add logging level

元气小坏坏 提交于 2020-01-10 14:32:29
问题 I have this code which works just fine for me. import logging import logging.handlers logger = None def create_logger(): global logger logger = logging.getLogger('Logger') logger.setLevel(logging.DEBUG) handler = logging.handlers.RotatingFileHandler("C:/Users/user/Desktop/info.log", maxBytes=1000000, backupCount=20) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) create_logger() logger.info("Text

Python3 add logging level

孤街浪徒 提交于 2020-01-10 14:32:04
问题 I have this code which works just fine for me. import logging import logging.handlers logger = None def create_logger(): global logger logger = logging.getLogger('Logger') logger.setLevel(logging.DEBUG) handler = logging.handlers.RotatingFileHandler("C:/Users/user/Desktop/info.log", maxBytes=1000000, backupCount=20) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) create_logger() logger.info("Text

How to install pygame for python3.5 in Ubuntu16.04?

孤街浪徒 提交于 2020-01-10 11:14:52
问题 I've spent hours for installing pygame , but it I didn't succeed. I want a detailed installing instruction for pygame in python3.5 in Ubuntu16.04. And I think it's a meaningful work for other people. 回答1: You probably do not have pip3.5 installed, so I believe you it's not been easy. So one solution may be to start installing pip3.5 . Based on this article on how to install pip3 in Ubuntu, here's a possible solution for your problem. First install setuptools for Python 3 sudo apt-get install

How to install pygame for python3.5 in Ubuntu16.04?

為{幸葍}努か 提交于 2020-01-10 11:10:54
问题 I've spent hours for installing pygame , but it I didn't succeed. I want a detailed installing instruction for pygame in python3.5 in Ubuntu16.04. And I think it's a meaningful work for other people. 回答1: You probably do not have pip3.5 installed, so I believe you it's not been easy. So one solution may be to start installing pip3.5 . Based on this article on how to install pip3 in Ubuntu, here's a possible solution for your problem. First install setuptools for Python 3 sudo apt-get install

how to define dynamic nested loop python function

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-10 02:43:08
问题 a = [1] b = [2,3] c = [4,5,6] d = [a,b,c] for x0 in d[0]: for x1 in d[1]: for x2 in d[2]: print(x0,x1,x2) Result: 1 2 4 1 2 5 1 2 6 1 3 4 1 3 5 1 3 6 Perfect, now my question is how to define this to function, considering ofcourse there could be more lists with values. The idea is to get function, which would dynamicaly produce same result. Is there a way to explain to python: "do 8 nested loops for example"? 回答1: You can use itertools to calculate the products for you and can use the *

How to auto-activate a tkinter simpledialog pop-up window?

纵饮孤独 提交于 2020-01-07 02:54:20
问题 I have this function inside one of my python scripts which throws up a Tkinter simple dialog screen to ask for some simple user-input. The function works. However, there are 2 problems with it. It opens up two windows, while all I need is one. But if I remove the master = Tk() I get the error: AttributeError: 'NoneType' object has no attribute 'winfo_viewable' It would be nice to at one point figure that one out, but my main problem however is the second one: Whenever the simple dialog screen

“is” and “id” in Python 3.5 [duplicate]

眉间皱痕 提交于 2020-01-07 01:49:27
问题 This question already has answers here : Why does comparing strings using either '==' or 'is' sometimes produce a different result? (14 answers) Closed 3 years ago . i have questions: I'm using python 3.5 , win7-32bit system. Here's my code: a=3 b=3 print(id(a)) print(id(b)) it returns: 1678268160 1678268160 So we could know that a and b reference to same object. But here comes the question: a=3 b=3 print( id(a) is id(b) ) It return : False I dont understand why this happened, I think it

“is” and “id” in Python 3.5 [duplicate]

送分小仙女□ 提交于 2020-01-07 01:49:14
问题 This question already has answers here : Why does comparing strings using either '==' or 'is' sometimes produce a different result? (14 answers) Closed 3 years ago . i have questions: I'm using python 3.5 , win7-32bit system. Here's my code: a=3 b=3 print(id(a)) print(id(b)) it returns: 1678268160 1678268160 So we could know that a and b reference to same object. But here comes the question: a=3 b=3 print( id(a) is id(b) ) It return : False I dont understand why this happened, I think it